Fix high CPU usage when encountering non-file URI workspaces #1396
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.
Fixes #1394
There are two issues here:
file://
URIs and we were getting their filesystem path when ends up being an empty string.foo://bar.html
), causes the server to be initialized with a file URI offile://.
and rootPath of/.
. I'd expect them to use thefoo://
scheme but that does not happen. I think it's super reasonable to have the server refuse a workspace folder that is the filesystem root. This check is definitely not exhaustive (may not handle network shares, arbitrary mounts, different drives on Windows, etc…) but this is probably "good enough" to detect this situation.Both of these results in the folder being treated as
/
and results in a file search from the root causing super high CPU usage. I've also added a check insidegetProject
so files with non-file schemes are ignored. They'll get afsPath
of empty string as well and as such won't match any project. The VSCode extension already does this at the extension level but we weren't doing it in the language server.