Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Debounce diagnostics calls on documentChange events
Browse files Browse the repository at this point in the history
  • Loading branch information
tgecho committed Aug 17, 2019
1 parent 723310c commit b38d762
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { HTMLPlugin } from './plugins/HTMLPlugin';
import { CSSPlugin } from './plugins/CSSPlugin';
import { wrapFragmentPlugin } from './api/wrapFragmentPlugin';
import { TypeScriptPlugin } from './plugins/TypeScriptPlugin';
import _ from 'lodash';

namespace TagCloseRequest {
export const type: RequestType<
Expand Down Expand Up @@ -114,13 +115,16 @@ export function startServer() {
manager.getCodeActions(evt.textDocument, evt.range, evt.context),
);

manager.on('documentChange', async document => {
const diagnostics = await manager.getDiagnostics({ uri: document.getURL() });
connection.sendDiagnostics({
uri: document.getURL(),
diagnostics,
});
});
manager.on(
'documentChange',
_.debounce(async document => {
const diagnostics = await manager.getDiagnostics({ uri: document.getURL() });
connection.sendDiagnostics({
uri: document.getURL(),
diagnostics,
});
}, 500),
);

connection.listen();
}

0 comments on commit b38d762

Please sign in to comment.