aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/events/change_text_document.ts
blob: 2e998e889ba17db5e22a59ad805e7e2eca1c702b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as vscode from 'vscode';

import {
    SyntaxTreeContentProvider,
    syntaxTreeUri,
} from '../commands/syntaxTree';

export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
    return (event: vscode.TextDocumentChangeEvent) => {
        const doc = event.document;
        if (doc.languageId !== 'rust') {
            return;
        }
        afterLs(() => {
            syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri);
        });
    };
}

// We need to order this after LS updates, but there's no API for that.
// Hence, good old setTimeout.
function afterLs(f: () => any) {
    setTimeout(f, 10);
}