From c36ddce36fce8e2e11a822366df81c5c15644a14 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 21 Jun 2025 17:21:03 +0900 Subject: Add bg-cancel action to ignore running background transforms Close #4430 Example: # Implement popup that disappears after 1 second # * Use footer as the popup # * Use `bell` to ring the terminal bell # * Use `bg-transform-footer` to clear the footer after 1 second # * Use `bg-cancel` to ignore currently running background transform actions fzf --multi --list-border \ --bind 'enter:execute-silent(echo -n {+} | pbcopy)+bell' \ --bind 'enter:+transform-footer(echo Copied {} to clipboard)' \ --bind 'enter:+bg-cancel+bg-transform-footer(sleep 1)' --- test/test_core.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/test_core.rb b/test/test_core.rb index f714e1c3..b7eba741 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1964,4 +1964,21 @@ class TestCore < TestInteractive elapsed = Time.now - time assert elapsed < 2 end + + def test_bg_cancel + tmux.send_keys %(seq 0 1 | #{FZF} --bind 'space:bg-cancel+bg-transform-header(sleep {}; echo [{}])'), :Enter + tmux.until { assert_equal 2, it.match_count } + tmux.send_keys '1' + tmux.until { assert_equal 1, it.match_count } + tmux.send_keys :Space + tmux.send_keys :BSpace + tmux.until { assert_equal 2, it.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert lines.any_include?('[0]') } + sleep 2 + tmux.until do |lines| + assert lines.any_include?('[0]') + refute lines.any_include?('[1]') + end + end end -- cgit v1.2.3