From a7c7a189bc1d9588a2e59d7521a2242089058cff Mon Sep 17 00:00:00 2001 From: Alan Urmancheev Date: Fri, 15 Sep 2023 23:38:32 +0400 Subject: [PATCH] ToPath: percent decode input URI 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 #60 on GitHub. --- internal/lsp/text/edit.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/lsp/text/edit.go b/internal/lsp/text/edit.go index 3848358..177f87b 100644 --- a/internal/lsp/text/edit.go +++ b/internal/lsp/text/edit.go @@ -4,6 +4,7 @@ package text import ( "fmt" "io" + "net/url" "sort" "strings" @@ -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) return filename }