Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

alurm
Copy link

@alurm alurm commented Sep 15, 2023

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.

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.
@farhaven
Copy link
Contributor

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)
Copy link
Collaborator

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?

Copy link
Author

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.

@farhaven
Copy link
Contributor

farhaven commented Oct 26, 2024 via email

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.

In internal/lsp/text/edit.go, ToPath doesn't percent decode input URI
3 participants