TS7 LSP: documentHighlight returns nothing when the file path contains '@'
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- go
- Bereich
- backend-api-design
Rechercherichtung
Beginne mit tsc/internal/ls/documenthighlights.go:30, wo das Issue einen Vergleich von rohen URI-Strings nennt, und sieh dir tsc/internal/ls/lsconv/converters.go:315 an, um die URI-Kodierung zu verstehen. Reproduziere das Verhalten mit der bereitgestellten TypeScript-Datei in einem Pfad mit @ und vergleiche die Ergebnisse mit kodierter und nicht kodierter URI. Als erledigt gilt die Aufgabe, wenn die Dokumenthervorhebungen für beide URI-Formen alle drei Treffer zurückgeben; das Issue nennt keine Testdatei.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🔎 Search Terms
documentHighlight, document highlight, URI encoding, percent-encoding, %40, @ in path, Neovim, LSP
🕗 Version & Regression Information
- I was unable to test this on prior versions because this code is in the TS7 language server only. The old tsserver (through vtsls) does not have this problem.
I reproduced it with tsc --lsp 7.0.2. The same code is on main at ba1819f.
⏯ Playground Link
Not applicable. The problem is in the language server.
💻 Code
Put this file in a directory whose path contains @, for example /tmp/a@b/proj/x.ts, with an empty tsconfig.json next to it:
const foo = 1;
console.log(foo);
console.log(foo);
🙁 Actual behavior
textDocument/documentHighlight on foo (line 0, character 7) returns an empty array if the client sends the path with @ not encoded:
| URI that the client sends | Highlights |
|---|---|
file:///tmp/a@b/proj/x.ts |
0 |
file:///tmp/a%40b/proj/x.ts |
3 |
file:///tmp/plain/proj/x.ts |
3 |
Neovim sends the first form (vim.uri_from_fname("/tmp/a@b/x.ts") gives file:///tmp/a@b/x.ts). Thus, in Neovim, document highlights and features that use them (for example, jump to next reference) do not work in projects whose path contains @. Other requests, such as textDocument/references, work correctly on the same file.
🙂 Expected behavior
The server returns 3 highlights for all three URIs. The two a@b URIs identify the same file, and the server opens that file correctly from both forms.
Additional information about the issue
Cause. tsc/internal/ls/documenthighlights.go:30 filters the results with a raw string compare:
if mh.Uri == documentUri {
mh.Uricomes fromlsconv.FileNameToDocumentURI, which encodes@as%40(tsc/internal/ls/lsconv/converters.go:315).documentUriis the string that the client sent, without changes.
When the client does not encode @, the strings are different, and the filter removes all highlights. VS Code does not see this problem because vscode-uri also encodes @ as %40 (URI.file('/tmp/a@b/x.ts').toString() gives file:///tmp/a%40b/x.ts). Thus the two sides always agree.
Why this is a server problem. RFC 3986 permits @ in a path segment without encoding, so the client URI is valid. Also, the LSP specification (URI section) says:
Clients and servers should not assume that each other are encoding the same way (for example a client encoding colons in drive letters cannot assume server responses will have encoded colons).
Possible fix. Compare file names, not URI strings:
if mh.Uri.FileName() == documentUri.FileName() {
Another possible fix is to normalize documentUri one time before the loop. Other characters in extraEscapeReplacer (', (, ), *, +, ,, ;, =, !, $, &, and so on) probably cause the same problem with clients that do not encode them.
Related: #43261 had the same type of cause (a path-case mismatch caused document highlights to fail) in tsserver.
Environment
- Neovim v0.12.0-dev, Linux (WSL2)
tsc --lsp7.0.2
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 16.4k
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 148
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#64742 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsEvtl. vergeben @dmety hat das vor 5 Tagen übernommen. OffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/TypeScript#64661 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedEvtl. vergeben @RyanCavanaugh hat das vor 6 Tagen übernommen. OffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/TypeScript#64618 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
TypeScript 7 VS Code extension: a workspace "typescript" 7.x package is not detected, only "@typescript/native-preview", which is no longer publishedEvtl. vergeben @jakebailey hat das vor 6 Tagen übernommen. OffenNeeds Investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/TypeScript#64565 · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
`EFNoLeadingComments` suppresses synthesized leading comments in tsgo; Strada only suppresses source commentsEvtl. vergeben @weswigham hat das vor 13 Tagen übernommen. OffenNeeds Investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/TypeScript#64453 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
unbounded value for n in `/v1/logs` can panic/OOMEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offensmall item
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
canonical/pebble#1127 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 89/100
open-policy-agent/opa#9366 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
defect
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nats-io/nats-server#8752 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement needs-acceptance wg/router-models-inference-runtime
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
vllm-project/semantic-router#5015 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
fileserver: precompressed sidecar's Content-Encoding and Content-Length end up on error responsesEvtl. vergeben @NitinKumar004 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
caddyserver/caddy#8204 ·
Maintainer antworten meist innerhalb von 1 Tag