Add a disableLanguageService setting.#2392
Add a disableLanguageService setting.#2392sean-mcmanus merged 8 commits intomastermicrosoft/vscode-cpptools:masterfrom seanmcm/disableLanguageServiceSettingmicrosoft/vscode-cpptools:seanmcm/disableLanguageServiceSettingCopy head branch name to clipboard
Conversation
| "description": "The value to use for the system include path. If set, it overrides the system include path acquired via \"compilerPath\" and \"compileCommands\" settings.", | ||
| "scope": "resource" | ||
| }, | ||
| "C_Cpp.disableLanguageService": { |
There was a problem hiding this comment.
I was planning to expose this differently, via C_Cpp.intelliSenseEngine (until we refactor settings and have intelliSense.enabled).
There was a problem hiding this comment.
You mean a "Disabled" setting for intelliSenseEngine? I could do that.
| } | ||
|
|
||
| async function finalizeExtensionActivation(): Promise<void> { | ||
| if (vscode.workspace.getConfiguration("C_Cpp", null).get<boolean>("disableLanguageService")) { |
There was a problem hiding this comment.
It seems like this feature should be a little more involved than just this. What happens to all the commands that are registered in package.json? Are we able to remove the context menu items?
There was a problem hiding this comment.
Yeah, all the package.json and context menu stuff remains activated, but they don't do anything. I was thinking that didn't matter, and/or wait till people complain about that. I don't think there's a way to remove the package.json stuff without modifying the file and doing a Reload Window and/or splitting the extension into multiple ones and disabling the separate sub-extension.
| } | ||
|
|
||
| async function finalizeExtensionActivation(): Promise<void> { | ||
| if (vscode.workspace.getConfiguration("C_Cpp", null).get<string>("intelliSenseEngine") === "Disabled") { |
There was a problem hiding this comment.
There doesn't seem to be a way to re-enable the language server after it's been disabled. It also appears that disabling the language server after it has already been loaded will have no effect.
There was a problem hiding this comment.
Yeah, that was "by design" :)...my assumption was that users who wanted to use this setting wouldn't mind having to Reload Window for it to work.
There was a problem hiding this comment.
I added the reload prompt.
| // Used to save/re-execute commands used before the extension has activated (e.g. delayed by dependency downloading). | ||
| private delayedCommandsToExecute: Set<string>; | ||
| private tempCommands: vscode.Disposable[]; // Need to save this to unregister/dispose the temporary commands. | ||
| private isDisabled: boolean; |
There was a problem hiding this comment.
Since this is just about disabling the language server, I think this variable name should reflect that.
| public registerTempCommand(command: string): void { | ||
| this.tempCommands.push(vscode.commands.registerCommand(command, () => { | ||
| if (this.isDisabled) { | ||
| vscode.window.showInformationMessage("The C/C++ command is disabled due to C_Cpp.intelliSenseEngine set to Disabled."); |
There was a problem hiding this comment.
"This command is disabled when "C_Cpp.intelliSenseEngine" is set to "Disabled""
| util.promptForReloadWindowDueToSettingsChange(); | ||
| } | ||
| })); | ||
| Telemetry.logLanguageServerEvent("intelliSenseEngine disabled"); |
There was a problem hiding this comment.
we don't have any events with spaces in them that I am aware of and the normal telemetry should cover this already.
| Telemetry.logLanguageServerEvent("intelliSenseEngine disabled"); | ||
| return; | ||
| } else { | ||
| disposables.push(vscode.workspace.onDidChangeConfiguration(() => { |
There was a problem hiding this comment.
since the "true" case does an early return, you don't need to put this part in an "else" block.
…b.com/Microsoft/vscode-cpptools into seanmcm/disableLanguageServiceSetting
Fix for #785 .