Skip to content

Commit

Permalink
ToPath: percent decode input URI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alurm committed Sep 15, 2023
1 parent c6ffdf3 commit a7c7a18
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/lsp/text/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package text
import (
"fmt"
"io"
"net/url"
"sort"
"strings"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a7c7a18

Please sign in to comment.