aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r--editors/code/src/highlighting.ts42
1 files changed, 20 insertions, 22 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index d383d87ef..d4e961b5b 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -10,28 +10,26 @@ import { Ctx } from './ctx';
10export function activateHighlighting(ctx: Ctx) { 10export function activateHighlighting(ctx: Ctx) {
11 const highlighter = new Highlighter(ctx); 11 const highlighter = new Highlighter(ctx);
12 12
13 ctx.client.onReady().then(() => { 13 ctx.onNotification(
14 ctx.client.onNotification( 14 'rust-analyzer/publishDecorations',
15 'rust-analyzer/publishDecorations', 15 (params: PublishDecorationsParams) => {
16 (params: PublishDecorationsParams) => { 16 if (!ctx.config.highlightingOn) return;
17 if (!ctx.config.highlightingOn) return; 17
18 18 const targetEditor = vscode.window.visibleTextEditors.find(
19 const targetEditor = vscode.window.visibleTextEditors.find( 19 editor => {
20 editor => { 20 const unescapedUri = unescape(
21 const unescapedUri = unescape( 21 editor.document.uri.toString(),
22 editor.document.uri.toString(), 22 );
23 ); 23 // Unescaped URI looks like:
24 // Unescaped URI looks like: 24 // file:///c:/Workspace/ra-test/src/main.rs
25 // file:///c:/Workspace/ra-test/src/main.rs 25 return unescapedUri === params.uri;
26 return unescapedUri === params.uri; 26 },
27 }, 27 );
28 ); 28 if (!targetEditor) return;
29 if (!targetEditor) return; 29
30 30 highlighter.setHighlights(targetEditor, params.decorations);
31 highlighter.setHighlights(targetEditor, params.decorations); 31 },
32 }, 32 );
33 );
34 });
35 33
36 vscode.workspace.onDidChangeConfiguration( 34 vscode.workspace.onDidChangeConfiguration(
37 _ => highlighter.removeHighlights(), 35 _ => highlighter.removeHighlights(),