Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display prompt [Information Message] to restart the server when the omnisharp configuration changes #2316

Merged
merged 5 commits into from
May 24, 2018

Conversation

akshita31
Copy link
Contributor

Added an option change observer that subscribes to an Observable and shows the information message when there is a change in the configuration the server cares about and then restarts the server when "Restart" is clicked. Added unit tests for each of the components involved.

@akshita31 akshita31 requested a review from rchande May 16, 2018 20:10
@codecov
Copy link

codecov bot commented May 16, 2018

Codecov Report

Merging #2316 into master will increase coverage by 0.13%.
The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2316      +/-   ##
==========================================
+ Coverage   61.38%   61.51%   +0.13%     
==========================================
  Files          85       86       +1     
  Lines        3835     3851      +16     
  Branches      552      554       +2     
==========================================
+ Hits         2354     2369      +15     
- Misses       1311     1312       +1     
  Partials      170      170
Flag Coverage Δ
#integration 51.16% <78.12%> (+0.04%) ⬆️
#unit 83.34% <92.59%> (+0.63%) ⬆️
Impacted Files Coverage Δ
src/observables/CreateOptionStream.ts 100% <100%> (ø)
src/observers/OptionChangeObserver.ts 100% <100%> (ø)
src/main.ts 93.13% <100%> (+0.13%) ⬆️
src/observers/OptionProvider.ts 71.42% <66.66%> (-8.58%) ⬇️
src/features/diagnosticsProvider.ts 73.18% <0%> (-1.45%) ⬇️
src/observers/utils/ShowInformationMessage.ts 87.5% <0%> (+12.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4be8950...4d71611. Read the comment docs.

@akshita31
Copy link
Contributor Author

@DustinCampbell Are there any other options that we should consider here ?

@akshita31
Copy link
Contributor Author

akshita31 commented May 16, 2018

@colombod This test https://github.com/OmniSharp/omnisharp-vscode/pull/2316/files#diff-dd9d0618b9edb503c00be5f531debc27R78 is so cool. Thanks for the idea 🥇

@DustinCampbell
Copy link
Member

Where is the code where we decide which options should cause us to prompt an OmniSharp restart? Right now, it looks like we'll prompt on any change to the 'omnisharp' or 'csharp' configurations.

@akshita31
Copy link
Contributor Author

@DustinCampbell
Copy link
Member

@akshita31; Thanks! I was having trouble spotting that code for some reason. Looks good to me!

@colombod
Copy link
Member

@DustinCampell the magic of rx!

}
});

return () => disposable.dispose();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the line below are beyond my rx-fu, can you explain them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publishBehavior is used to create a behavior observable which has the initial value as Option.Read(). refCount() is used so that the dispose function on the observable is called only when all the observers who susbcribed to this observable invoke unsubscribe. This test verifies this behavior https://github.com/OmniSharp/omnisharp-vscode/pull/2316/files#diff-dd9d0618b9edb503c00be5f531debc27R78

let subscription = ConfigChangeObservable(optionObservable)
.subscribe(_ => {
let message = "OmniSharp configuration has changed. Would you like to relaunch the OmniSharp server with your changes?";
ShowInformationMessage(vscode, message, { title: "Restart Now", command: 'o.restart' });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have the button say "Restart OmniSharp"

}

function hasChanged(oldOptions: Options, newOptions: Options): boolean {
if (oldOptions.path != newOptions.path ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, you could write this return ...

@akshita31 akshita31 added this to the 1.16 milestone May 24, 2018
@akshita31 akshita31 merged commit 0a4c6cc into dotnet:master May 24, 2018
@akshita31 akshita31 deleted the config_changed branch May 24, 2018 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants