diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-07-27 10:38:08 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-07-27 11:30:25 +0900 |
| commit | 587df594b884c3649b14c8f19dfbcee78e74a0a9 (patch) | |
| tree | 23c9575ef902e8e8a5adaacad0473a87eede247d /src/reader.go | |
| parent | b896e0d3140e4a80725fe5a54a9703e4a46e8b65 (diff) | |
| download | fzf-587df594b884c3649b14c8f19dfbcee78e74a0a9.tar.gz | |
Fix incompatibility of adaptive height and 'start:reload'
This command would cause a deadlock and make fzf crash:
fzf --bind 'start:reload:ls' --height ~100%
Because,
1. 'start' event is handled by Terminal
2. When 'reload' is bound to 'start', fzf avoids starting the initial reader
3. Terminal waits for the initial input to find the right height when
adaptive height is used
4. Because the initial reader is not started, Terminal never gets the
initial list
5. No chance to trigger 'start:reload', hence deadlock
This commit fixes the above problem by extracting the reload command
bound to 'start' event and starting the initial reader with that command
instead of letting Terminal start it.
This commit also makes the environment variables available to
$FZF_DEFAULT_COMMAND.
FZF_DEFAULT_COMMAND='echo $FZF_QUERY' fzf --query foo
Fix #3944
Diffstat (limited to 'src/reader.go')
| -rw-r--r-- | src/reader.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/reader.go b/src/reader.go index a4049c4e..ccaf8c62 100644 --- a/src/reader.go +++ b/src/reader.go @@ -111,18 +111,20 @@ 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) { +func (r *Reader) ReadSource(inputChan chan string, root string, opts walkerOpts, ignores []string, initCmd string, initEnv []string) { r.startEventPoller() var success bool if inputChan != nil { success = r.readChannel(inputChan) + } else if len(initCmd) > 0 { + success = r.readFromCommand(initCmd, initEnv) } else if util.IsTty(os.Stdin) { cmd := os.Getenv("FZF_DEFAULT_COMMAND") if len(cmd) == 0 { success = r.readFiles(root, opts, ignores) } else { // We can't export FZF_* environment variables to the default command - success = r.readFromCommand(cmd, nil) + success = r.readFromCommand(cmd, initEnv) } } else { success = r.readFromStdin() |
