This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
fix(vscode): ignore incompatible versions of the binary and improve the restart logic #4022
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.
Summary
The main goal of this PR is to introduce a version check on the binary distribution that's loaded from the workspace. Versions of the
@rometools/cli-*
packages lower than0.9.0
did not include the language server, and as such will fail to initialize when spawned by the extension. I've added a simple check against the major and minor version of the package that to ignore versions that do not meet the current requirements of the extension and fall back to the bundled version of the binary if it's available.In addition to this, I also made a minor change to the handler of the "Restart LSP Server" command to skip trying to stop the server if its not already running and only try to start it instead. Finally, I've updated the logic of the
fileExists
function to also handle theFileNotFound
code that may also be returned by VSCode's filesystem functions.Test Plan
I've tested these changes with a local build of the extension on a workspace using version
0.8.0
of the npm package and verified the extension did not try to load the incompatible version of the binary.I've also tested the new restart logic by repeatedly stopping the Rome server process with an editor open until the extension stopped respawning it automatically, and verified the "Restart LSP Server" correctly spawned the server process again.