Skip to content

Commit 1483285

Browse files
committed
delay update annotator
1 parent 7f0d9d6 commit 1483285

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/annotator.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export function onDidChangeConfiguration(client: LanguageClient) {
3030
updateDecorations();
3131
}
3232

33+
let timeoutToReqAnn: NodeJS.Timer;
34+
3335
export function requestAnnotators(editor: vscode.TextEditor, client: LanguageClient) {
36+
clearTimeout(timeoutToReqAnn);
37+
timeoutToReqAnn = setTimeout(() => {
38+
requestAnnotatorsImpl(editor, client);
39+
}, 300);
40+
}
41+
42+
function requestAnnotatorsImpl(editor: vscode.TextEditor, client: LanguageClient) {
3443
if (!D_PARAM) {
3544
updateDecorations();
3645
}

src/extension.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ function onDidChangeWorkspaceFolders(event: vscode.WorkspaceFoldersChangeEvent)
6060
}
6161

6262
function onDidChangeTextDocument(event: vscode.TextDocumentChangeEvent) {
63-
if (activeEditor) {
64-
setTimeout(() => {
65-
Annotator.requestAnnotators(activeEditor, client);
66-
}, 0.1);
63+
if (activeEditor && activeEditor.document === event.document) {
64+
Annotator.requestAnnotators(activeEditor, client);
6765
}
6866
}
6967

@@ -110,7 +108,7 @@ function startClient() {
110108
}
111109
};
112110

113-
let socketMode = false;
111+
let socketMode = true;
114112
let serverOptions: ServerOptions;
115113
if (socketMode) {
116114
// The server is a started as a separate app and listens on port 5007

0 commit comments

Comments
 (0)