mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
Run bg-transform callbacks during wait instead of dropping them
Wait-block guard returned early for all actions but abort/cancel, silently discarding actAsync so bg-transform results completing mid-wait were lost. Let actAsync through since it's unrelated to the wait.
This commit is contained in:
+5
-2
@@ -6747,8 +6747,11 @@ func (t *Terminal) Loop() error {
|
|||||||
callback(a.a)
|
callback(a.a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// When wait-blocked, only allow abort/cancel
|
// When wait-blocked, only allow abort/cancel. Background transform
|
||||||
if t.waitBlocked {
|
// callbacks (actAsync) are let through since they're unrelated to the
|
||||||
|
// wait; blocking them would silently drop bg-transform results that
|
||||||
|
// complete while waiting.
|
||||||
|
if t.waitBlocked && a.t != actAsync {
|
||||||
if a.t == actAbort || a.t == actCancel {
|
if a.t == actAbort || a.t == actCancel {
|
||||||
t.unblockWait()
|
t.unblockWait()
|
||||||
t.pendingActions = nil
|
t.pendingActions = nil
|
||||||
|
|||||||
@@ -1185,6 +1185,15 @@ 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_bg_transform
|
||||||
|
# A bg-transform result is unrelated to the wait, so it's applied while the
|
||||||
|
# wait is still blocking rather than dropped. The long read keeps the wait
|
||||||
|
# blocked so the (instant) bg-transform completes during the block; the
|
||||||
|
# header must show while '(..)' is still displayed.
|
||||||
|
tmux.send_keys %((seq 100; sleep 2) | #{FZF} --bind 'start:bg-transform-header(echo hello)+search(5)+wait'), :Enter
|
||||||
|
tmux.until { |lines| assert(lines.any_include?('(..)') && lines.any_include?('hello')) }
|
||||||
|
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