I have implemented a LSP for a VSCode extension that provides a series of diagnostics for the opened document(s).
The execution of the function that evaluates the document occurs in the onDidChangeContent
event (server side):
documents.onDidChangeContent(async event => {
await validateTextDocument(event.document)
})
Now the issue comes when the document is quite long and you start typing or making changes rapidly. The validateTextDocument()
can take a few seconds for these long documents and since documents.onDidChangeContent()
will fire on each keystroke, the computer starts overloading with too many requests.
Is there any way to prevent the client from making any more requests until the server has responded? or even cancel the onDidChangeContent
altogether?
Thanks in advance