diff options
author | Aleksey Kladov <[email protected]> | 2019-12-31 16:22:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-31 16:22:43 +0000 |
commit | e4b588868f822b9c200a8ce77d24bfab5aeca4b8 (patch) | |
tree | 6241f2088d0b1d8eeae9cceef4aee74a48d31993 /editors/code/src/highlighting.ts | |
parent | 1327aed7f6289043091aa9179282030c6f13ddbe (diff) |
Refactor status activation
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r-- | editors/code/src/highlighting.ts | 42 |
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'; | |||
10 | export function activateHighlighting(ctx: Ctx) { | 10 | export 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(), |