Skip to content

Compare document highlight URIs by file path - #65531

Closed
Josué Barros (joshbarros) wants to merge 1 commit into
microsoft:mainfrom
joshbarros:fix/64758-document-highlight-uri
Closed

Josué Barros (joshbarros) wants to merge 1 commit into
microsoft:mainfrom
joshbarros:fix/64758-document-highlight-uri

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #64758

ProvideDocumentHighlights filtered 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 because vscode-uri also encodes @ as %40.

This compares DocumentUri.PathKey(l.CaseSensitivity()) instead, which normalizes the escaping and also keeps the case-insensitive behavior.

The new TestDocumentHighlightUnescapedAtSign opens /home/projects/a@b/x.ts with the unescaped URI file:///home/projects/a@b/x.ts and expects the three foo highlights. 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/ls and gofmt -l: clean.

Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.

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
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:16
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 16, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

TS7 LSP: documentHighlight returns nothing when the file path contains '@'

4 participants