Fix parsing/generating Windows-style file: URIs#2572
Merged
dantleech merged 1 commit intophpactor:masterfrom Mar 2, 2024
Merged
Fix parsing/generating Windows-style file: URIs#2572dantleech merged 1 commit intophpactor:masterfrom
dantleech merged 1 commit intophpactor:masterfrom
Conversation
Contributor
Author
|
This is a bit of a follow-up for #2568, after I better understood how things work. |
dantleech
reviewed
Feb 28, 2024
dbc0892 to
8ae48d6
Compare
This fixes features like "go to definition" on Windows. In a file: URI, after the scheme, there are two slashes, then the 'host' (usually empty), then another slash, then the 'path'. For example: file:///foo/bar.php file:///C:/foo/bar.php That's three leading slashes total, and the third slash is not a part of the path, but a part of the URI format itself; it just looks like that with Unix-style filesystem paths. Unfortunately, this means you can't just prepend 'file://' to a filesystem path and get a valid file: URI. Fortunately, `TextDocumentUri::fromString(…)` accepts filesystem paths too, so document that and use it in test cases. Replace invalid URIs with two slashes in other test cases too to avoid confusion. See: https://en.wikipedia.org/wiki/File_URI_scheme
8ae48d6 to
4c0cd87
Compare
Collaborator
|
nice work! |
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.
This fixes features like "go to definition" on Windows.
In a file: URI, after the scheme, there are two slashes, then the 'host' (usually empty), then another slash, then the 'path'. For example:
file:///foo/bar.php
file:///C:/foo/bar.php
That's three leading slashes total, and the third slash is not a part of the path, but a part of the URI format itself; it just looks like that with Unix-style filesystem paths.
Unfortunately, this means you can't just prepend 'file://' to a filesystem path and get a valid file: URI. Fortunately,
TextDocumentUri::fromString(…)accepts filesystem paths too, so document that and use it in test cases. Replace invalid URIs with two slashes in other test cases too to avoid confusion.See: https://en.wikipedia.org/wiki/File_URI_scheme