[PATCH] D66406: [clangd] Update themeRuleMatcher when color theme changes in vscode extension.
Johan Vikström via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 07:03:36 PDT 2019
jvikstrom updated this revision to Diff 217638.
jvikstrom added a comment.
Updated to new master.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66406/new/
https://reviews.llvm.org/D66406
Files:
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===================================================================
--- clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ 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<string>('colorTheme');
+}
+
// Parameters for the semantic highlighting (server-side) push notification.
// Mirrors the structure in the semantic highlighting proposal for LSP.
interface SemanticHighlightingParams {
@@ -56,6 +61,8 @@
scopeLookupTable: string[][];
// The object that applies the highlightings clangd sends.
highlighter: Highlighter;
+ // The current color theme used for colorization.
+ private currentColorThemeName: string;
// Any disposables that should be cleaned up when clangd crashes.
private subscriptions: vscode.Disposable[] = [];
fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
@@ -70,9 +77,9 @@
}
async loadCurrentTheme() {
- const themeRuleMatcher = new ThemeRuleMatcher(
- await loadTheme(vscode.workspace.getConfiguration('workbench')
- .get<string>('colorTheme')));
+ this.currentColorThemeName = getCurrentThemeName();
+ const themeRuleMatcher =
+ new ThemeRuleMatcher(await loadTheme(this.currentColorThemeName));
this.highlighter.initialize(themeRuleMatcher);
}
@@ -91,6 +98,16 @@
// highlighter being created.
this.highlighter = new Highlighter(this.scopeLookupTable);
this.subscriptions.push(vscode.Disposable.from(this.highlighter));
+ // Adds a listener to reload the theme when it changes.
+ this.subscriptions.push(
+ 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();
// Event handling for handling with TextDocuments/Editors lifetimes.
this.subscriptions.push(vscode.window.onDidChangeVisibleTextEditors(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66406.217638.patch
Type: text/x-patch
Size: 2498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190828/d395eff5/attachment.bin>
More information about the cfe-commits
mailing list