diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index d736a6fc4..478055e6c 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -21,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. 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..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; @@ -430,17 +431,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; } @@ -475,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)); }); } @@ -508,17 +510,29 @@ class DefaultClient implements Client { return Promise.reject(""); }; - return this.queueTaskWithTimeout(provideConfigurationAsync, 1000, tokenSource).then( + return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, 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"); }