-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger a window reload on use O# option change and others to workaro…
…und restart bug
- Loading branch information
Showing
8 changed files
with
150 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Observable } from 'rxjs'; | ||
import { CommonOptionsThatTriggerReload, LanguageServerOptionsThatTriggerReload, Options } from '../shared/options'; | ||
import { HandleOptionChanges, OptionChangeObserver, OptionChanges } from '../shared/observers/optionChangeObserver'; | ||
import ShowInformationMessage from '../shared/observers/utils/showInformationMessage'; | ||
import Disposable from '../disposable'; | ||
import { vscode } from '../vscodeAdapter'; | ||
|
||
export function registerLanguageServerOptionChanges(optionObservable: Observable<Options>, vscode: vscode): Disposable { | ||
const optionChangeObserver: OptionChangeObserver = { | ||
getRelevantOptions: () => { | ||
return { | ||
changedCommonOptions: CommonOptionsThatTriggerReload, | ||
changedLanguageServerOptions: LanguageServerOptionsThatTriggerReload, | ||
changedOmnisharpOptions: [], | ||
}; | ||
}, | ||
handleOptionChanges(optionChanges) { | ||
handleLanguageServerOptionChanges(optionChanges, vscode); | ||
}, | ||
}; | ||
|
||
const disposable = HandleOptionChanges(optionObservable, optionChangeObserver); | ||
return disposable; | ||
} | ||
|
||
function handleLanguageServerOptionChanges(changedOptions: OptionChanges, vscode: vscode): void { | ||
if (changedOptions.changedCommonOptions.length == 0 && changedOptions.changedLanguageServerOptions.length == 0) { | ||
// No changes to relevant options, do nothing. | ||
return; | ||
} | ||
|
||
const reloadTitle = 'Reload Window'; | ||
const reloadCommand = 'workbench.action.reloadWindow'; | ||
if (changedOptions.changedCommonOptions.find((key) => key === 'useOmnisharpServer')) { | ||
// If the user has changed the useOmnisharpServer flag we need to reload the window. | ||
ShowInformationMessage( | ||
vscode, | ||
'The useOmnisharpServer option has changed. Please reload the window to apply the change', | ||
{ | ||
title: reloadTitle, | ||
command: reloadCommand, | ||
} | ||
); | ||
return; | ||
} | ||
|
||
// Typically when we have a regular config change, we can just restart the server, but due to | ||
// https://github.com/dotnet/vscode-csharp/issues/5882 we need to reload the window when using devkit. | ||
const message = 'C# configuration has changed. Would you like to reload the window to apply your changes?'; | ||
ShowInformationMessage(vscode, message, { title: reloadTitle, command: reloadCommand }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { HandleOptionChanges, OptionChangeObserver } from '../shared/observers/optionChangeObserver'; | ||
import { CommonOptionsThatTriggerReload, OmnisharpOptionsThatTriggerReload, Options } from '../shared/options'; | ||
import ShowInformationMessage from '../shared/observers/utils/showInformationMessage'; | ||
import { vscode } from '../vscodeAdapter'; | ||
import { Observable } from 'rxjs'; | ||
import Disposable from '../disposable'; | ||
|
||
export function registerOmnisharpOptionChanges(vscode: vscode, optionObservable: Observable<Options>): Disposable { | ||
const optionChangeObserver: OptionChangeObserver = { | ||
getRelevantOptions: () => { | ||
return { | ||
changedCommonOptions: CommonOptionsThatTriggerReload, | ||
changedLanguageServerOptions: [], | ||
changedOmnisharpOptions: OmnisharpOptionsThatTriggerReload, | ||
}; | ||
}, | ||
handleOptionChanges(_) { | ||
const message = | ||
'C# configuration has changed. Would you like to relaunch the Language Server with your changes?'; | ||
const title = 'Restart Language Server'; | ||
const commandName = 'o.restart'; | ||
ShowInformationMessage(vscode, message, { title: title, command: commandName }); | ||
}, | ||
}; | ||
|
||
const disposable = HandleOptionChanges(optionObservable, optionChangeObserver); | ||
return disposable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters