langserver: Avoid re-processing open files after file saving #1372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1366
Context
A common use case for
workspace/didChangeWatchedFiles
is to receive updates about files changed outside of the IDE - such as when the user runsgit checkout
to switch branches.The LSP spec isn't 100% clear about whether clients should always send
workspace/didChangeWatchedFiles
also for open files. A popular language client (VS Code) always does - i.e. we receive bothtextDocument/didSave
on save and then subsequentlyworkspace/didChangeWatchedFiles
even if the file content has not changed - only the modification timestamp has.This leads us to processing the exact same files (content-wise) multiple times in row (1st on
textDocument/didChange
2nd and any other time onworkspace/didChangeWatchedFiles
as followed aftertextDocument/didSave
), in turn wasting resources.Solution
Reduce the work we do after file saving by assuming that changes have already been processed as part of
textDocument/didChange
.