mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
Block 'start:wait' during initial load
- Init searchInProgress before reader starts so start:wait waits for the first complete result set instead of no-op'ing - Add test_wait_action_start
This commit is contained in:
+5
-1
@@ -1169,7 +1169,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
|||||||
lastAction: actStart,
|
lastAction: actStart,
|
||||||
lastFocus: minItem.Index(),
|
lastFocus: minItem.Index(),
|
||||||
lastActivity: time.Now(),
|
lastActivity: time.Now(),
|
||||||
numLinesCache: make(map[int32]numLinesCacheValue)}
|
// Consider the initial load a search in progress so 'start:wait' blocks
|
||||||
|
// until the first result set is complete. Set here, before the reader
|
||||||
|
// starts, so the first final() result correctly clears it.
|
||||||
|
searchInProgress: true,
|
||||||
|
numLinesCache: make(map[int32]numLinesCacheValue)}
|
||||||
if opts.AcceptNth != nil {
|
if opts.AcceptNth != nil {
|
||||||
t.acceptNth = opts.AcceptNth(t.delimiter)
|
t.acceptNth = opts.AcceptNth(t.delimiter)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1173,6 +1173,18 @@ class TestCore < TestInteractive
|
|||||||
tmux.until { |lines| assert_equal 1, lines.match_count }
|
tmux.until { |lines| assert_equal 1, lines.match_count }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_wait_action_start
|
||||||
|
# 'start:wait' blocks on the initial load until reading completes
|
||||||
|
tmux.send_keys %((seq 100; sleep 60) | #{FZF} --bind 'start:wait'), :Enter
|
||||||
|
tmux.until { |lines| assert_equal 100, lines.match_count }
|
||||||
|
tmux.until { |lines| assert lines.any_include?('(..)') }
|
||||||
|
tmux.send_keys 'C-c'
|
||||||
|
tmux.until { |lines| refute lines.any_include?('(..)') }
|
||||||
|
# Ctrl-C cancels the wait; fzf keeps running and accepts input again
|
||||||
|
tmux.send_keys '99'
|
||||||
|
tmux.until { |lines| assert_equal 1, lines.match_count }
|
||||||
|
end
|
||||||
|
|
||||||
def test_clear_selection
|
def test_clear_selection
|
||||||
tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter
|
tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter
|
||||||
tmux.until { |lines| assert_equal 100, lines.match_count }
|
tmux.until { |lines| assert_equal 100, lines.match_count }
|
||||||
|
|||||||
Reference in New Issue
Block a user