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

Commit b38d762

Browse files
committed
Debounce diagnostics calls on documentChange events
1 parent 723310c commit b38d762

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/server.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { HTMLPlugin } from './plugins/HTMLPlugin';
1313
import { CSSPlugin } from './plugins/CSSPlugin';
1414
import { wrapFragmentPlugin } from './api/wrapFragmentPlugin';
1515
import { TypeScriptPlugin } from './plugins/TypeScriptPlugin';
16+
import _ from 'lodash';
1617

1718
namespace TagCloseRequest {
1819
export const type: RequestType<
@@ -114,13 +115,16 @@ export function startServer() {
114115
manager.getCodeActions(evt.textDocument, evt.range, evt.context),
115116
);
116117

117-
manager.on('documentChange', async document => {
118-
const diagnostics = await manager.getDiagnostics({ uri: document.getURL() });
119-
connection.sendDiagnostics({
120-
uri: document.getURL(),
121-
diagnostics,
122-
});
123-
});
118+
manager.on(
119+
'documentChange',
120+
_.debounce(async document => {
121+
const diagnostics = await manager.getDiagnostics({ uri: document.getURL() });
122+
connection.sendDiagnostics({
123+
uri: document.getURL(),
124+
diagnostics,
125+
});
126+
}, 500),
127+
);
124128

125129
connection.listen();
126130
}

0 commit comments

Comments
 (0)