aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/events/change_active_text_editor.ts
blob: 3440aa0c37501e205371b0e5d8bd36dd371f3cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { TextEditor } from 'vscode';
import { TextDocumentIdentifier } from 'vscode-languageclient';

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(),
    };
    const decorations = await Server.client.sendRequest<Decoration[]>('m/decorationsRequest', params);
    Server.highlighter.setHighlights(editor, decorations);
}