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

Allow walking multiple root directories #4109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions man/man1/fzf.1
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,8 @@ Determines the behavior of the built-in directory walker that is used when
.br

.TP
.B "\-\-walker\-root=DIR"
The root directory from which to start the built-in directory walker.
.B "\-\-walker\-root=DIRS"
Comma-separated list of directory names to start the built-in directory walker.
The default value is the current working directory.

.TP
Expand Down
2 changes: 1 addition & 1 deletion src/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Usage: fzf [options]
Directory traversal (Only used when $FZF_DEFAULT_COMMAND is not set)
--walker=OPTS [file][,dir][,follow][,hidden] (default: file,follow,hidden)
--walker-root=DIR Root directory from which to start walker (default: .)
--walker-root=DIRS Comma-separated list of directories to walk (default: .)
--walker-skip=DIRS Comma-separated list of directory names to skip
(default: .git,node_modules)
Expand Down
8 changes: 7 additions & 1 deletion src/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fzf

import (
"bytes"
"strings"
"context"
"io"
"io/fs"
Expand Down Expand Up @@ -301,7 +302,12 @@ func (r *Reader) readFiles(root string, opts walkerOpts, ignores []string) bool
}
return nil
}
return fastwalk.Walk(&conf, root, fn) == nil
roots := strings.Split(root, ",")
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 {
Expand Down