aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/events/change_active_text_editor.ts39
-rw-r--r--editors/code/src/extension.ts4
2 files changed, 26 insertions, 17 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 @@
1import { TextEditor } from 'vscode'; 1import { TextEditor } from 'vscode';
2import { TextDocumentIdentifier } from 'vscode-languageclient'; 2import { TextDocumentIdentifier } from 'vscode-languageclient';
3 3
4import {
5 SyntaxTreeContentProvider,
6 syntaxTreeUri
7} from '../commands/syntaxTree';
4import { Decoration } from '../highlighting'; 8import { Decoration } from '../highlighting';
5import { Server } from '../server'; 9import { Server } from '../server';
6 10
7export async function handle(editor: TextEditor | undefined) { 11export 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}
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index 894334c55..941beba18 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -94,13 +94,13 @@ export function activate(context: vscode.ExtensionContext) {
94 notifications.publishDecorations.handle 94 notifications.publishDecorations.handle
95 ] 95 ]
96 ]; 96 ];
97 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
97 98
98 // The events below are plain old javascript events, triggered and handled by vscode 99 // The events below are plain old javascript events, triggered and handled by vscode
99 vscode.window.onDidChangeActiveTextEditor( 100 vscode.window.onDidChangeActiveTextEditor(
100 events.changeActiveTextEditor.handle 101 events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider)
101 ); 102 );
102 103
103 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
104 disposeOnDeactivation( 104 disposeOnDeactivation(
105 vscode.workspace.registerTextDocumentContentProvider( 105 vscode.workspace.registerTextDocumentContentProvider(
106 'rust-analyzer', 106 'rust-analyzer',