summaryrefslogtreecommitdiff
path: root/src/options.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-07-27 10:38:08 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-07-27 11:30:25 +0900
commit587df594b884c3649b14c8f19dfbcee78e74a0a9 (patch)
tree23c9575ef902e8e8a5adaacad0473a87eede247d /src/options.go
parentb896e0d3140e4a80725fe5a54a9703e4a46e8b65 (diff)
downloadfzf-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/options.go')
-rw-r--r--src/options.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/options.go b/src/options.go
index d32daf10..1593d6f8 100644
--- a/src/options.go
+++ b/src/options.go
@@ -2964,17 +2964,18 @@ func ParseOptions(useDefaults bool, args []string) (*Options, error) {
return opts, nil
}
-func (opts *Options) reloadOnStart() bool {
- // Not compatible with --filter
- if opts.Filter != nil {
- return false
- }
+func (opts *Options) extractReloadOnStart() string {
+ cmd := ""
if actions, prs := opts.Keymap[tui.Start.AsEvent()]; prs {
+ filtered := []*action{}
for _, action := range actions {
if action.t == actReload || action.t == actReloadSync {
- return true
+ cmd = action.a
+ } else {
+ filtered = append(filtered, action)
}
}
+ opts.Keymap[tui.Start.AsEvent()] = filtered
}
- return false
+ return cmd
}