summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Vieth <charlie.vieth@gmail.com>2024-07-08 09:21:37 -0400
committerGitHub <noreply@github.com>2024-07-08 22:21:37 +0900
commit2dbc874e3dfa381b2e5492c94bf4056d4a36f3f1 (patch)
tree9c631f59dbe4c4cb7a8752999a2a6f7b50291e6e
parent039a2f1d04417d6aae0a3197227f1cba15bcb22b (diff)
downloadfzf-2dbc874e3dfa381b2e5492c94bf4056d4a36f3f1.tar.gz
Update charlievieth/fastwalk to use forward-slashes on WSL and MSYS (#3907)
This commit changes FZF to enforce that all paths are joined with forward-slashes when running on WSL or MSYS even when the FZF binary was compiled for Windows. Update: github.com/charlievieth/fastwalk Fixes: https://github.com/junegunn/fzf/issues/3859 --------- Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--src/reader.go22
3 files changed, 23 insertions, 5 deletions
diff --git a/go.mod b/go.mod
index 4ab49803..5ffa67a1 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
module github.com/junegunn/fzf
require (
- github.com/charlievieth/fastwalk v1.0.4
+ github.com/charlievieth/fastwalk v1.0.7-0.20240703190418-87029d931815
github.com/gdamore/tcell/v2 v2.7.4
github.com/mattn/go-isatty v0.0.20
github.com/mattn/go-shellwords v1.0.12
diff --git a/go.sum b/go.sum
index c0ccde0c..6cd4c53e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/charlievieth/fastwalk v1.0.4 h1:EG3y5L1XBa8VftvpONuQlfe5sNuf1xzGpm59bdgCDwo=
-github.com/charlievieth/fastwalk v1.0.4/go.mod h1:JSfglY/gmL/rqsUS1NCsJTocB5n6sSl9ApAqif4CUbs=
+github.com/charlievieth/fastwalk v1.0.7-0.20240703190418-87029d931815 h1:4PRbYm9OMgH0bcdZZqMXA/AoOvpGy4l0H6g9Au/kgGA=
+github.com/charlievieth/fastwalk v1.0.7-0.20240703190418-87029d931815/go.mod h1:rV19+IF9Y2TYQNy4MqEk5M/spNHjKsA0i71yrsv2p4E=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
diff --git a/src/reader.go b/src/reader.go
index 9d4b2f46..b9368f07 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -233,14 +233,32 @@ func isSymlinkToDir(path string, de os.DirEntry) bool {
return false
}
+func trimPath(path string) string {
+ bytes := stringBytes(path)
+
+ for len(bytes) > 1 && bytes[0] == '.' && (bytes[1] == '/' || bytes[1] == '\\') {
+ bytes = bytes[2:]
+ }
+
+ if len(bytes) == 0 {
+ return "."
+ }
+
+ return byteString(bytes)
+}
+
func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool {
r.killed = false
- conf := fastwalk.Config{Follow: opts.follow}
+ conf := fastwalk.Config{
+ Follow: opts.follow,
+ // Use forward slashes when running a Windows binary under WSL or MSYS
+ ToSlash: fastwalk.DefaultToSlash(),
+ }
fn := func(path string, de os.DirEntry, err error) error {
if err != nil {
return nil
}
- path = filepath.Clean(path)
+ path = trimPath(path)
if path != "." {
isDir := de.IsDir()
if isDir || opts.follow && isSymlinkToDir(path, de) {