Skip to content

Normalize Windows drive letter case in workspace document URIs - #719

Open
Sanjays2402 wants to merge 1 commit into
python-lsp:developfrom
Sanjays2402:fix/normalize-drive-letter-doc-uris
Open

Normalize Windows drive letter case in workspace document URIs#719
Sanjays2402 wants to merge 1 commit into
python-lsp:developfrom
Sanjays2402:fix/normalize-drive-letter-doc-uris

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #697

Windows drive letters are case-insensitive, so a client may send file:///C:/foo (RFC 8089) or file:///c:/foo for the same file. uris.from_fs_path lower-cases the drive letter but Workspace._docs stored URIs verbatim, so the two spellings became separate dictionary keys — a document opened under one spelling was invisible under the other, and lookups silently fell back to stale on-disk content instead of the in-memory version.

Adds uris.normalize and uses it for every _docs key. Non-drive paths are unchanged. New tests fail without the fix and pass with it.

Windows drive letters are case-insensitive and clients may send either
`file:///C:/foo` (RFC 8089) or `file:///c:/foo` for the same file.
`uris.from_fs_path` lower-cases the drive letter, but `Workspace._docs`
stored URIs verbatim, so the two spellings became distinct dictionary
keys. A document opened under one spelling was then invisible under the
other, and lookups silently fell back to reading stale content from disk
instead of the in-memory version.

Add `uris.normalize` and use it for every `_docs` key, so a document is
found regardless of the drive letter case the client used. Non-drive
paths are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URI Normalization Inconsistency Causes Workspace Cache Misses on Windows

1 participant