Skip to content

Commit

Permalink
fix: add interval for onDidChangeContent
Browse files Browse the repository at this point in the history
close #1663
  • Loading branch information
johnsoncodehk committed Aug 6, 2022
1 parent d996ddd commit 18b62d1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vue-language-server/src/projects.ts
Expand Up @@ -196,9 +196,16 @@ export function createProjects(

const req = ++documentUpdatedReq;
const delay = await lsConfigs?.getConfiguration<number>('volar.diagnostics.delay');

let lastCheckCancelAt = 0;
let _isCancel = false;
const isCancel = async () => {
await shared.sleep(0); // wait for onDidChangeContent polling
return req !== documentUpdatedReq;
if (Date.now() - lastCheckCancelAt >= 5) {
await shared.sleep(5); // wait for onDidChangeContent polling
_isCancel = req !== documentUpdatedReq;
lastCheckCancelAt = Date.now();
}
return _isCancel;
};

const changeDocs = docUri ? [getDocumentSafely(documents, docUri)].filter(shared.notEmpty) : [];
Expand Down

0 comments on commit 18b62d1

Please sign in to comment.