aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/events/change_text_document.ts
blob: 89488bc61ef0912f6cf3afb1699fca59b2a2fe50 (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);
}