summaryrefslogtreecommitdiff
path: root/src/reader.go
diff options
context:
space:
mode:
authormsabathier <115698101+msabathier@users.noreply.github.com>2024-11-25 11:25:30 +0100
committerGitHub <noreply@github.com>2024-11-25 19:25:30 +0900
commitbee80a730f945c05ac0167130b9204206371d570 (patch)
tree5b36d16a05f9a35159477987e1bfeb10b6df58a5 /src/reader.go
parentac3e24c99c221ae2e4e0a8fd6d6d1e0078260ab4 (diff)
downloadfzf-bee80a730f945c05ac0167130b9204206371d570.tar.gz
Allow walking multiple root directories (#4109)
Co-authored-by: Martin Sabathier <martin.sabathier.ext@corys.fr> Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diffstat (limited to 'src/reader.go')
-rw-r--r--src/reader.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/reader.go b/src/reader.go
index b2531c3a..80387bac 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -120,7 +120,7 @@ func (r *Reader) readChannel(inputChan chan string) bool {
}
// ReadSource reads data from the default command or from standard input
-func (r *Reader) ReadSource(inputChan chan string, root string, opts walkerOpts, ignores []string, initCmd string, initEnv []string, readyChan chan bool) {
+func (r *Reader) ReadSource(inputChan chan string, roots []string, opts walkerOpts, ignores []string, initCmd string, initEnv []string, readyChan chan bool) {
r.startEventPoller()
var success bool
signalReady := func() {
@@ -137,7 +137,7 @@ func (r *Reader) ReadSource(inputChan chan string, root string, opts walkerOpts,
cmd := os.Getenv("FZF_DEFAULT_COMMAND")
if len(cmd) == 0 {
signalReady()
- success = r.readFiles(root, opts, ignores)
+ success = r.readFiles(roots, opts, ignores)
} else {
success = r.readFromCommand(cmd, initEnv, signalReady)
}
@@ -265,7 +265,7 @@ func trimPath(path string) string {
return byteString(bytes)
}
-func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool {
+func (r *Reader) readFiles(roots []string, opts walkerOpts, ignores []string) bool {
conf := fastwalk.Config{
Follow: opts.follow,
// Use forward slashes when running a Windows binary under WSL or MSYS
@@ -301,7 +301,11 @@ func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool
}
return nil
}
- return fastwalk.Walk(&conf, root, fn) == nil
+ noerr := true
+ for _, root := range roots {
+ noerr = noerr && (fastwalk.Walk(&conf, root, fn) == nil)
+ }
+ return noerr
}
func (r *Reader) readFromCommand(command string, environ []string, signalReady func()) bool {