From bded9ce7eb8188b45dd6f6bc9ce0b332275ec353 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Thu, 19 Jul 2018 11:49:58 -0700 Subject: [PATCH 1/3] Add a setting to silence configuration provider warnings --- Extension/CHANGELOG.md | 3 ++- Extension/package.json | 10 +++++++++ Extension/src/LanguageServer/client.ts | 27 ++++++++++++++++++------ Extension/src/LanguageServer/settings.ts | 1 + 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index c2d9ccd8e..6a3b0f112 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,6 +1,6 @@ # C/C++ for Visual Studio Code Change Log -## Version 0.17.7: July 18, 2018 +## Version 0.17.7: July 19, 2018 * Fix `Go to Definition` for code scoped with an aliased namespace. [#387](https://github.com/Microsoft/vscode-cpptools/issues/387) * Fix incorrect IntelliSense errors with template template-arguments. [#1014](https://github.com/Microsoft/vscode-cpptools/issues/1014) * Fix crash when using designated initializer lists. [#1440](https://github.com/Microsoft/vscode-cpptools/issues/1440) @@ -13,6 +13,7 @@ * Fix indexing of the entire root drive on Windows when no is folder open. [#2216](https://github.com/Microsoft/vscode-cpptools/issues/2216) * Disable the config provider message for headers outside the workspace and when debugging. [#2221](https://github.com/Microsoft/vscode-cpptools/issues/2221) * Add `Change Configuration Provider...` command. [#2224](https://github.com/Microsoft/vscode-cpptools/issues/2224) +* Add a setting to silence configuration provider warnings. [#2292](https://github.com/Microsoft/vscode-cpptools/issues/2292) * Fix out-of-memory crash with `#include` code actions when no folder is open. [#2225](https://github.com/Microsoft/vscode-cpptools/issues/2225) * Fix `intelliSenseMode` with custom config providers on Windows. [#2228](https://github.com/Microsoft/vscode-cpptools/issues/2228) * Fix variables not resolving in `macFrameworkPath`. [#2234](https://github.com/Microsoft/vscode-cpptools/issues/2234) diff --git a/Extension/package.json b/Extension/package.json index 95873ffc4..78cd2b1b2 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -250,6 +250,16 @@ "description": "Defines the editor behavior for when the Enter key is pressed inside a multiline or single line comment block.", "scope": "resource" }, + "C_Cpp.configurationWarnings": { + "type": "string", + "enum": [ + "Enabled", + "Disabled" + ], + "default": "Enabled", + "description": "Determines whether pop up notifications will be shown when a configuration provider extension is unable to provide a configuration for a source file.", + "scope": "resource" + }, "C_Cpp.default.includePath": { "type": [ "array", diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index d9688785e..16e9c7eb5 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -430,17 +430,18 @@ class DefaultClient implements Client { let folderStr: string = (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) ? "the '" + this.Name + "'" : "this"; const message: string = `${provider.name} would like to configure IntelliSense for ${folderStr} folder.`; const allow: string = "Allow"; - const notNow: string = "Not Now"; - const dontAskAgain: string = "Don't Ask Again"; - vscode.window.showInformationMessage(message, allow, notNow, dontAskAgain).then(result => { + const dontAllow: string = "Don't Allow"; + const askLater: string = "Ask Me Later"; + vscode.window.showInformationMessage(message, allow, dontAllow, askLater).then(result => { switch (result) { case allow: { this.configuration.updateCustomConfigurationProvider(provider.extensionId).then(() => { telemetry.logLanguageServerEvent("customConfigurationProvider", { "providerId": provider.extensionId }); }); + ask.Value = false; break; } - case dontAskAgain: { + case dontAllow: { ask.Value = false; break; } @@ -508,17 +509,29 @@ class DefaultClient implements Client { return Promise.reject(""); }; - return this.queueTaskWithTimeout(provideConfigurationAsync, 1000, tokenSource).then( + return this.queueTaskWithTimeout(provideConfigurationAsync, 2000, tokenSource).then( (configs: SourceFileConfigurationItem[]) => { if (configs && configs.length > 0) { this.sendCustomConfigurations(configs); } }, () => { - if (!this.isExternalHeader(document) && !vscode.debug.activeDebugSession) { + let settings: CppSettings = new CppSettings(this.RootUri); + if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document) && !vscode.debug.activeDebugSession) { + const dismiss: string = "Dismiss"; + const disable: string = "Disable Warnings"; vscode.window.showInformationMessage( `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + - `Settings from the '${configName}' configuration will be used instead.`); + `Settings from the '${configName}' configuration will be used instead.`, + dismiss, + disable).then(response => { + switch (response) { + case disable: { + settings.toggleSetting("configurationWarnings", "Enabled", "Disabled"); + break; + } + } + }); } }); } diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index 9fca99695..738f8f402 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -48,6 +48,7 @@ export class CppSettings extends Settings { public get workspaceParsingPriority(): boolean { return super.Section.get("workspaceParsingPriority"); } public get exclusionPolicy(): boolean { return super.Section.get("exclusionPolicy"); } public get commentContinuationPatterns(): (string | CommentPattern)[] { return super.Section.get<(string | CommentPattern)[]>("commentContinuationPatterns"); } + public get configurationWarnings(): string { return super.Section.get("configurationWarnings"); } public get preferredPathSeparator(): string { return super.Section.get("preferredPathSeparator"); } public get defaultIncludePath(): string[] { return super.Section.get("default.includePath"); } public get defaultDefines(): string[] { return super.Section.get("default.defines"); } From 7425bdea3197cfab73ad246fdb0945724b0e12d7 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Thu, 19 Jul 2018 11:53:10 -0700 Subject: [PATCH 2/3] missed a timeout location --- Extension/src/LanguageServer/client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index 16e9c7eb5..c3af87f00 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -30,6 +30,7 @@ import { getTestHook, TestHook } from '../testHook'; import { getCustomConfigProviders, CustomConfigurationProviderCollection, CustomConfigurationProvider1 } from '../LanguageServer/customProviders'; let ui: UI; +const configProviderTimeout: number = 2000; interface NavigationPayload { navigation: string; @@ -476,7 +477,7 @@ class DefaultClient implements Client { let task: () => Thenable = () => { return currentProvider.provideConfigurations(documentUris, tokenSource.token); }; - this.queueTaskWithTimeout(task, 1000, tokenSource).then(configs => this.sendCustomConfigurations(configs)); + this.queueTaskWithTimeout(task, configProviderTimeout, tokenSource).then(configs => this.sendCustomConfigurations(configs)); }); } @@ -509,7 +510,7 @@ class DefaultClient implements Client { return Promise.reject(""); }; - return this.queueTaskWithTimeout(provideConfigurationAsync, 2000, tokenSource).then( + return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( (configs: SourceFileConfigurationItem[]) => { if (configs && configs.length > 0) { this.sendCustomConfigurations(configs); From 48c06ea5afb187bd0b86fd33fd0c6f27afe18240 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Thu, 19 Jul 2018 12:09:04 -0700 Subject: [PATCH 3/3] reorder changelog --- Extension/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 6ebc8cffa..478055e6c 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -13,7 +13,6 @@ * Fix indexing of the entire root drive on Windows when no is folder open. [#2216](https://github.com/Microsoft/vscode-cpptools/issues/2216) * Disable the config provider message for headers outside the workspace and when debugging. [#2221](https://github.com/Microsoft/vscode-cpptools/issues/2221) * Add `Change Configuration Provider...` command. [#2224](https://github.com/Microsoft/vscode-cpptools/issues/2224) -* Add a setting to silence configuration provider warnings. [#2292](https://github.com/Microsoft/vscode-cpptools/issues/2292) * Fix out-of-memory crash with `#include` code actions when no folder is open. [#2225](https://github.com/Microsoft/vscode-cpptools/issues/2225) * Fix `intelliSenseMode` with custom config providers on Windows. [#2228](https://github.com/Microsoft/vscode-cpptools/issues/2228) * Fix formatting not working on Windows if the VC++ 2015 redist isn't installed. [#2232](https://github.com/Microsoft/vscode-cpptools/issues/2232) @@ -22,6 +21,7 @@ * Fix `#include` autocomplete with Mac framework headers. [#2251](https://github.com/Microsoft/vscode-cpptools/issues/2251) * Fix for debugging to support empty arguments for debuggee. [#2258](https://github.com/Microsoft/vscode-cpptools/issues/2258) * Fix `Go to Definition` bug (missing symbols outside the workspace). [#2281](https://github.com/Microsoft/vscode-cpptools/issues/2281) +* Add a setting to silence configuration provider warnings. [#2292](https://github.com/Microsoft/vscode-cpptools/issues/2292) * Fix for debugging async Visual C++ causing debugger to hang. * Fix `main` snippet.