Repository navigation
Compare document highlight URIs by file path - #65531
Closed
Josué Barros (joshbarros) wants to merge 1 commit into
Closed
Josué Barros (joshbarros) wants to merge 1 commit into
Josué Barros (joshbarros) wants to merge 1 commit into
Conversation
ProvideDocumentHighlights filtered results with a raw URI string compare. The server percent-encodes characters such as @ when it converts a file name back to a URI, while clients such as Neovim leave @ unescaped, so every highlight was dropped for paths containing it. Compare path keys instead, which normalizes escaping and respects the host case sensitivity. Add an LSP test that opens a file under a directory containing @ with an unescaped URI and expects the three highlights. Fixes microsoft#64758
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change to normalize URI comparisons when filtering document highlights.
No open issues 🎉
What changed in this PR
Fixes #64758 by comparing document highlight URIs as normalized file paths, so different percent-encoding styles no longer cause valid highlights to be dropped.
Changes:
- Uses case-aware path keys instead of raw URI strings to select highlights for the current file.
- Adds an LSP regression test verifying that an unescaped
@in a file URI returns all three expected highlights.
| File | Description |
|---|---|
tsc/internal/lsp/server_documenthighlight_test.go |
Adds regression coverage for document highlights with an unescaped @ URI. |
tsc/internal/ls/documenthighlights.go |
Compares normalized path keys when filtering document highlights. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #64758
ProvideDocumentHighlightsfiltered per-file results with a raw URI string compare. When the server converts a file name back to a URI it percent-encodes characters such as@, while clients such as Neovim leave@unescaped (vim.uri_from_fname). The strings differed, so every highlight was removed for paths containing@. Other clients hide this becausevscode-urialso encodes@as%40.This compares
DocumentUri.PathKey(l.CaseSensitivity())instead, which normalizes the escaping and also keeps the case-insensitive behavior.The new
TestDocumentHighlightUnescapedAtSignopens/home/projects/a@b/x.tswith the unescaped URIfile:///home/projects/a@b/x.tsand expects the threefoohighlights. Without the change it gets 0.Validation:
go test ./tsc/internal/lsp -run TestDocumentHighlightUnescapedAtSign -count=1: fails without the change, passes with it.go test ./tsc/internal/lsp ./tsc/internal/ls -count=1: pass.go vet ./tsc/internal/lsp ./tsc/internal/lsandgofmt -l: clean.Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.