diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts @@ -5,6 +5,11 @@ import * as vscodelc from 'vscode-languageclient'; import * as vscodelct from 'vscode-languageserver-types'; +function getCurrentThemeName() { + return vscode.workspace.getConfiguration('workbench') + .get('colorTheme'); +} + // Parameters for the semantic highlighting (server-side) push notification. // Mirrors the structure in the semantic highlighting proposal for LSP. interface SemanticHighlightingParams { @@ -49,6 +54,10 @@ scopeLookupTable: string[][]; // The rules for the current theme. themeRuleMatcher: ThemeRuleMatcher; + // The current color theme used for colorization. + currentColorThemeName: string; + // Disposable that should be cleaned up. + disposable: vscode.Disposable; fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) { // Extend the ClientCapabilities type and add semantic highlighting // capability to the object. @@ -61,9 +70,9 @@ } async loadCurrentTheme() { - this.themeRuleMatcher = new ThemeRuleMatcher( - await loadTheme(vscode.workspace.getConfiguration('workbench') - .get('colorTheme'))); + this.currentColorThemeName = getCurrentThemeName(); + this.themeRuleMatcher = + new ThemeRuleMatcher(await loadTheme(this.currentColorThemeName)); } initialize(capabilities: vscodelc.ServerCapabilities, @@ -76,6 +85,14 @@ if (!serverCapabilities.semanticHighlighting) return; this.scopeLookupTable = serverCapabilities.semanticHighlighting.scopes; + this.disposable = vscode.workspace.onDidChangeConfiguration((conf) => { + if (!conf.affectsConfiguration('workbench')) + // Configuration could not have affected the current colorTheme. + return; + const newColorTheme = getCurrentThemeName(); + if (newColorTheme != this.currentColorThemeName) + this.loadCurrentTheme(); + }); this.loadCurrentTheme(); }