diff options
author | Ville Penttinen <[email protected]> | 2019-03-03 20:03:37 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-03-03 20:03:37 +0000 |
commit | 0db95fc812d2c839e847527b774dfda170266cec (patch) | |
tree | 89f05d9798cf77a2798ff5fd643649cbb9071e77 /editors/code/src/events | |
parent | 1b4e0ec1c868c7f2a0eef1e59bfa382db85a6900 (diff) |
Allow syntax tree to update when changing files
Previously when using the file based syntax tree, it would not update until a
change had been made in the new file. Now we automatically update the syntax
tree to match the current file.
Diffstat (limited to 'editors/code/src/events')
-rw-r--r-- | editors/code/src/events/change_active_text_editor.ts | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/editors/code/src/events/change_active_text_editor.ts b/editors/code/src/events/change_active_text_editor.ts index af295b2ec..64be56225 100644 --- a/editors/code/src/events/change_active_text_editor.ts +++ b/editors/code/src/events/change_active_text_editor.ts | |||
@@ -1,23 +1,32 @@ | |||
1 | import { TextEditor } from 'vscode'; | 1 | import { TextEditor } from 'vscode'; |
2 | import { TextDocumentIdentifier } from 'vscode-languageclient'; | 2 | import { TextDocumentIdentifier } from 'vscode-languageclient'; |
3 | 3 | ||
4 | import { | ||
5 | SyntaxTreeContentProvider, | ||
6 | syntaxTreeUri | ||
7 | } from '../commands/syntaxTree'; | ||
4 | import { Decoration } from '../highlighting'; | 8 | import { Decoration } from '../highlighting'; |
5 | import { Server } from '../server'; | 9 | import { Server } from '../server'; |
6 | 10 | ||
7 | export async function handle(editor: TextEditor | undefined) { | 11 | export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { |
8 | if ( | 12 | return async function handle(editor: TextEditor | undefined) { |
9 | !Server.config.highlightingOn || | 13 | if (!editor || editor.document.languageId !== 'rust') { |
10 | !editor || | 14 | return; |
11 | editor.document.languageId !== 'rust' | 15 | } |
12 | ) { | 16 | |
13 | return; | 17 | syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri); |
14 | } | 18 | |
15 | const params: TextDocumentIdentifier = { | 19 | if (!Server.config.highlightingOn) { |
16 | uri: editor.document.uri.toString() | 20 | return; |
21 | } | ||
22 | |||
23 | const params: TextDocumentIdentifier = { | ||
24 | uri: editor.document.uri.toString() | ||
25 | }; | ||
26 | const decorations = await Server.client.sendRequest<Decoration[]>( | ||
27 | 'rust-analyzer/decorationsRequest', | ||
28 | params | ||
29 | ); | ||
30 | Server.highlighter.setHighlights(editor, decorations); | ||
17 | }; | 31 | }; |
18 | const decorations = await Server.client.sendRequest<Decoration[]>( | ||
19 | 'rust-analyzer/decorationsRequest', | ||
20 | params | ||
21 | ); | ||
22 | Server.highlighter.setHighlights(editor, decorations); | ||
23 | } | 32 | } |