-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Find diagnostics for both C:
and c:
forms of a path
#3347
feat: Find diagnostics for both C:
and c:
forms of a path
#3347
Conversation
I checked all uses of |
I think this is a more general problem than just this instance. Anytime URLs are compared you risk issues, for example in My idea would be to create a newtype We would then replace all usages of |
@poliorcetics This is a draft of what I've been working on. It's quite clunky since URLs are often used to interface with other types in the |
c0c75a0
to
6d7fa93
Compare
@Frojdholm I had already started on your suggestion on my side, I looked at yours in diagonal, it seems like we got similar solutions, except for the Edit: thanks anyway for the work and the suggestion, both are appreciated 👍 |
6d7fa93
to
33bf867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, I haven't had the opportunity to try it out yet, but it seems fairly similar to what I've implemented 👍
I have two design related comments:
- I don't think this problem is restricted to Windows. Imagine for example accessing files on a Windows server through a Linux host.
- I think having the extra field in
NormalizedUrl
complicates the design somewhat. I guess you did it for performance to avoid having to always calculate the new path? Have you measured the performance differences between the two approaches? I don't know how slow/performance critical the URL handling is, but if it's not critical I would personally prefer a simpler implementation.
I have not yet pushed my changes, I was benchmarking both approach (normalizing at init and storing the result vs normalizing during comparison). The worst case in both approach is a Windows path URL of the form So, worst case:
I expect performances to be worse on Windows because the allocator is (reputedly) not as good and most machines are not a Macbook Pro with the biggest M1 Pro, but even at twice the time, this is still good. I'll continue on the road of normalizing at construction because overall all the comparisons are faster with it and the code is clearer IMO (e.g the comparison function for the normalize-during-compare case needs a little help to be faster, and it still does not reach the pre-normalized case by ~10%). On a macOS install, with local paths (so no drive letter Of course my benchmarks are probably not that representative, but they at least show both approach are sufficiently fast and the first one will do much less small and repeated allocations. |
33bf867
to
c6b2b15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very thorough benchmarking 👏
400700d
to
2f55acb
Compare
2f55acb
to
bc13b64
Compare
Rebased on recent master, it was conflicting |
bc13b64
to
d7c4876
Compare
3807b7c
to
d9f565f
Compare
8d8fc48
to
9d4203d
Compare
1801051
to
27216c0
Compare
27216c0
to
286f08e
Compare
`Document::url()` uses `Document::path()` which is just a reference to `Document.path`. Since LSPs can send either a path with an uppercase or lowercase drive letter, we need to check for the other option when the first fails. We do this throughout Helix by introducing `NormalizedUrl` which takes care of the conversion and delegates to its base `Url` when needed. If future conversions are needed, they can be added here instead of having to repeat them all over the place.
…se()` where possible. Also, remove one usage point of `NormalizedUrl` because it was constructed only to be immediately destroyed.
286f08e
to
f1ceeaa
Compare
\cc @pascalkuthe Sorry for the delay on this PR, I've been hoping to find a way to do this without an additional wrapper type. |
The official URI reference implementation for the LSP spec is aware of this problem and even has tests for it. More importantly when an URI that is encoded to a string (which is done when it's sent server -> client/client -> serve) the driver litter is always converted to lower case: Sadly the rust URL crate exposed by LSP types doesn't seem to perform any kind of normalization like this at any point. Given that the driver letters sent by any LSP conformant server (or at-least those that work with VSCode?) should always be lowercase it should hopefully be enough for us to be careful to always lowercase the driver letters of any paths before turning them into an I sincerely hope that all LS actually stick to this send everything lowercase rule (but at-least all LS that are written in nodejs should as they would be using the official LSP uri library). Otherwise we need to somehow intercept messages somewhere early in the LSP client and lowercase the driver letter. Regardless I am not a fan of introducing a new normalized path type that stores two versions of the URI. We should just normalize all our URIs to be lower-cased to match VSCode and the spec here |
Yeah that won't happen. Relying on that when the rest of the computing world uses uppercase letters was a mistake from the LSP spec IMO. We can avoid the problem if we lowercase drive letters everywhere but we absolutely shouldn't rely on LSPs doing the right thing |
Actually an even easier solution: Do we really need to store an URI instead of just a |
Does helix intend to support remote editing one day (like |
I think @archseer sentiment on the topic (#3721 (comment)) was mostly to use |
The arguments on the issue are pretty much what I would have said about sshfs, the idea of it is nice, in practice it's not that useful because of its inherent limitations. Lowercasing drive letters all the time seems more forward-compatible than using |
I am not convinced that remote editing belongs in the core editor (that issue is labeled with The future proofing argument doesn't really make sense here as helix fundamentally only deals in
All usecases only work with |
Document::url()
usesDocument::path()
which is just a reference toDocument.path
. Since LSPscan send either a path with an uppercase or lowercase drive letter, we need to check for the other
option when the first fails.
We do this throughout Helix by introducing
NormalizedUrl
which takes care of the conversion anddelegates to its base
Url
when needed. If future conversions are needed, they can be added hereinstead of having to repeat them all over the place.
Closes #3267