Fix empty diagnostics on Windows from file URI drive-letter mismatch - #17
Open
bskim wants to merge 2 commits into
Open
Fix empty diagnostics on Windows from file URI drive-letter mismatch#17bskim wants to merge 2 commits into
bskim wants to merge 2 commits into
Conversation
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.
Problem
On Windows, the
diagnosticstool always returns no results, even when thelanguage server reports real errors. This affects servers that do not implement
pull diagnostics (
textDocument/diagnostic) and rely on thepublishDiagnosticspush path, such as typescript-language-server.
Root cause
The diagnostics store is keyed by file URI, but the write and read paths produce
different URIs for the same file on Windows:
publishDiagnosticsarrives with a lowercased, percent-encoded drive:file:///c%3A/workspace/src/index.tspathToFileURL(absPath).href, which yields an uppercase,unencoded drive:
file:///C:/workspace/src/index.tsdiagnosticsStore.get(uri)therefore misses and returns an empty array. The twoforms do not even match case-insensitively because of the
%3Avs:difference. POSIX is unaffected since file URIs there have no drive prefix.
Captured from typescript-language-server on Windows:
symbols,goto_definition, andfind_referencesare unaffected because theyuse direct request/response rather than the push store.
Fix
Add
normalizeDiagnosticUriand apply it on both the store write and read. Itonly reconciles the Windows drive prefix (lowercases the drive letter, decodes
the
%3Acolon) and returns POSIX URIs untouched, so case-sensitive paths arenever collapsed. Guarded by
process.platform === "win32".Also isolates two
createSpawnCommandtests that implicitly assumedtypescript-language-server is absent from the host PATH; they now pass an empty
PATH so resolution is deterministic regardless of the developer's machine.
Verification
normalizeDiagnosticUriunit tests: Windows didOpen/publish URIs match,drive-only lowering preserves path case, POSIX URIs unchanged and
non-colliding (red before fix, green after)
type errors returned 0 diagnostics before, 4 after
npx vitest run: 32 passed, 1 skippednpx tsc --noEmit: cleannpx biome check: cleanSummary by cubic
Fixes missing diagnostics on Windows by normalizing file URIs so
publishDiagnosticsentries match lookups. Also makes Windows spawn-command tests deterministic.normalizeDiagnosticUrito reconcile Windows drive prefixes (file:///C:/vsfile:///c%3A/); lowers only the drive letter, preserves path case, and runs only on Windows.createSpawnCommandtests by passing emptyPATHandPATHEXT.Written for commit 33f819e. Summary will update on new commits.