-
Notifications
You must be signed in to change notification settings - Fork 25
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
ToPath: percent decode input URI #61
base: master
Are you sure you want to change the base?
Conversation
This is useful in cases where initial path contains special characters. For example, path containing "c++" needs to be properly decoded, otherwise Acme will try to open file containing %2B%2B, which is wrong. Issue 9fans#60 on GitHub.
This is particularly helpful when running LSPs in the context of Bazel-managed TypeScript code. |
@@ -127,6 +128,7 @@ func ToURI(filename string) protocol.DocumentURI { | |||
// ToPath converts URI to filename. | |||
func ToPath(uri protocol.DocumentURI) string { | |||
filename, _ := CutPrefix(string(uri), "file://") | |||
filename, _ = url.PathUnescape(filename) |
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.
Don't you still need to CutPrefix
?
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.
I don't know, but I used this version with clangd I think, but I'm not sure about edge cases.
Whether it's required seems to depend on the language server. The Typescript language server seems to be happy without cutting the `file://` prefix off. It probably can't hurt to do both though, right?
…On Mon, Oct 21, 2024 at 06:50:08AM GMT, Fazlul Shahriar wrote:
@fhs commented on this pull request.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
In internal/lsp/text/edit.go:
> @@ -127,6 +128,7 @@ func ToURI(filename string) protocol.DocumentURI {
// ToPath converts URI to filename.
func ToPath(uri protocol.DocumentURI) string {
filename, _ := CutPrefix(string(uri), "file://")
+ filename, _ = url.PathUnescape(filename)
Don't you still need to CutPrefix?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.*Message ID: <9fans/acme-lsp/pull/
***@***.***>
--
Gregor
|
@alurm Would you be able to add the prefix-cutting back on top of your changes? If you don't want to/don't have the time, I can also open a new PR with both changes. |
@farhaven, I can try to do that, but I don't understand the message, maybe I'm missing something. Prefix cutting applies on the line before my change — I didn't change this part I believe. Can you please explain what you guys meant and what do you want? If it would be easier for you to create a PR — feel free, but I'd be happy to understand what you guys meant about not cutting the prefix. And I can push a change on top — if I understand what's needed. |
This is useful in cases where initial path contains special characters.
For example, path containing "c++" needs to be properly decoded, otherwise Acme will try to open file containing %2B%2B, which is wrong.
Partially fixes #60 on GitHub.