diff options
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 af295b2ecba..64be562250e 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 @@ import { TextEditor } from 'vscode'; import { TextDocumentIdentifier } from 'vscode-languageclient'; +import { + SyntaxTreeContentProvider, + syntaxTreeUri +} from '../commands/syntaxTree'; import { Decoration } from '../highlighting'; import { Server } from '../server'; -export async function handle(editor: TextEditor | undefined) { - if ( - !Server.config.highlightingOn || - !editor || - editor.document.languageId !== 'rust' - ) { - return; - } - const params: TextDocumentIdentifier = { - uri: editor.document.uri.toString() +export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { + return async function handle(editor: TextEditor | undefined) { + if (!editor || editor.document.languageId !== 'rust') { + return; + } + + syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri); + + if (!Server.config.highlightingOn) { + return; + } + + const params: TextDocumentIdentifier = { + uri: editor.document.uri.toString() + }; + const decorations = await Server.client.sendRequest<Decoration[]>( + 'rust-analyzer/decorationsRequest', + params + ); + Server.highlighter.setHighlights(editor, decorations); }; - const decorations = await Server.client.sendRequest<Decoration[]>( - 'rust-analyzer/decorationsRequest', - params - ); - Server.highlighter.setHighlights(editor, decorations); } |
