diff --git a/Extension/package.json b/Extension/package.json index 100a842b3..2233caec8 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -12,7 +12,7 @@ }, "license": "SEE LICENSE IN LICENSE.txt", "engines": { - "vscode": "^1.22.0" + "vscode": "^1.23.0" }, "bugs": { "url": "https://github.com/Microsoft/vscode-cpptools/issues", @@ -146,6 +146,14 @@ "description": "Controls whether inactive preprocessor blocks are colored differently than active code. This setting is ignored by the Tag Parser engine.", "scope": "resource" }, + "C_Cpp.inactiveRegionOpacity": { + "type:": "number", + "default": 0.55, + "Description": "Controls the opacity of inactive preprocessor blocks. Scales between 0.1 and 1.0. This setting only applies when inactive region dimming is enabled.", + "scope": "resource", + "minimum": 0.1, + "maximum": 1 + }, "C_Cpp.formatting": { "type": "string", "enum": [ @@ -1481,4 +1489,4 @@ "binaries": [] } ] -} +} \ No newline at end of file diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index 4010d3953..acb288097 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -705,12 +705,12 @@ class DefaultClient implements Client { } private updateInactiveRegions(params: InactiveRegionParams): void { - let renderOptions: vscode.DecorationRenderOptions = { - light: { color: "rgba(175,175,175,1.0)" }, - dark: { color: "rgba(155,155,155,1.0)" }, + let settings: CppSettings = new CppSettings(this.RootUri); + + let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({ + opacity: settings.inactiveRegionOpacity.toString(), rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen - }; - let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType(renderOptions); + }); // We must convert to vscode.Ranges in order to make use of the API's let ranges: vscode.Range[] = []; @@ -736,7 +736,6 @@ class DefaultClient implements Client { this.inactiveRegionsDecorations.set(params.uri, toInsert); } - let settings: CppSettings = new CppSettings(this.RootUri); if (settings.dimInactiveRegions) { // Apply the decorations to all *visible* text editors let editors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => e.document.uri.toString() === params.uri); diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index 40a3557f9..766142db6 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -40,6 +40,7 @@ export class CppSettings extends Settings { public get intelliSenseEngineFallback(): string { return super.Section.get("intelliSenseEngineFallback"); } public get errorSquiggles(): string { return super.Section.get("errorSquiggles"); } public get dimInactiveRegions(): boolean { return super.Section.get("dimInactiveRegions"); } + public get inactiveRegionOpacity(): number { return super.Section.get("inactiveRegionOpacity"); } public get autoComplete(): string { return super.Section.get("autocomplete"); } public get loggingLevel(): string { return super.Section.get("loggingLevel"); } public get navigationLength(): number { return super.Section.get("navigation.length", 60); }