From d83eb2800a09d86e17c0339d86bd1f22f68164a8 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 13 Jan 2025 00:13:31 +0900 Subject: Add change-nth action Example: # Start with --nth 1, then 2, then 3, then back to the default, 1 echo 'foo foobar foobarbaz' | fzf --bind 'space:change-nth(2|3|)' --nth 1 -q foo Close #4172 Close #3109 --- test/test_go.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/test_go.rb b/test/test_go.rb index db2d8f1d..b40bfb42 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -3718,6 +3718,29 @@ class TestGoFZF < TestBase BLOCK tmux.until { assert_block(block, _1) } end + + def test_change_nth + input = [ + 'foo bar bar bar bar', + 'foo foo bar bar bar', + 'foo foo foo bar bar', + 'foo foo foo foo bar' + ] + writelines(input) + tmux.send_keys %(#{FZF} -qfoo -n1 --bind 'space:change-nth:2|3|4|5|' < #{tempname}), :Enter + + tmux.until { |lines| assert_equal 4, lines.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert_equal 3, lines.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert_equal 2, lines.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert_equal 1, lines.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert_equal 0, lines.match_count } + tmux.send_keys :Space + tmux.until { |lines| assert_equal 4, lines.match_count } + end end module TestShell -- cgit v1.2.3