Move RuboCop file watching to the server #2982
Merged
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.
Motivation
Closes #1457
This was originally attempted in #1921 and #2510. This PR moves watching
.rubocop.yml
to the server, so that we can avoid a full server restart and instead just create a new instance of the RuboCop runner.This PR still suffers from the same issue reported in both previous attempts: trying to clear existing diagnostics after changing
.rubocop.yml
simply does not work. I believe this must be some sort of bug in the client or some assumption we're not satisfying. Clearing diagnostics works normally when closing files ontextDocument/didClose
notifications, so I see no reason why it wouldn't work while processing a did change watched files notification.Despite the bug, since we're trying to improve stability of the LSP, I think it's still worth moving forward. Launching the server is still the most critical part in our entire life cycle and reducing the amount of times we restart helps prevent unnecessary pain for developers. Additionally, simply editing the file with the stale diagnostics already makes them go away immediately, so the bug is not that terrible.
I created an issue to discuss the bug with the maintainers of the protocol microsoft/vscode-languageserver-node#1594.
Implementation
Stopped restarting the server on
.rubocop.yml
and.rubocop
modifications. Instead, we watch the files in the server and simply re-create the instance of the runner.Note that this has the added benefit of working on any editor.