From 1707b8cdba42492a88b3fc43c15c20d219c5ce2b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 25 Dec 2023 23:43:46 +0900 Subject: Add 'transform' action to conditionally perform a series of actions 'transform' action runs an external command that prints a series of actions to perform. # Disallow selecting an empty line echo -e "1. Hello\n2. Goodbye\n\n3. Exit" | fzf --reverse --header 'Select one' \ --bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"' # Move cursor past the empty line echo -e "1. Hello\n2. Goodbye\n\n3. Exit" | fzf --reverse --header 'Select one' \ --bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"' \ --bind 'focus:transform:[[ -n {} ]] && exit; [[ {fzf:action} =~ up$ ]] && echo up || echo down' Close #3368 Close #2980 --- test/test_go.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/test_go.rb b/test/test_go.rb index 5a9c48b7..771064ee 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -2016,6 +2016,13 @@ class TestGoFZF < TestBase tmux.until { |lines| assert_equal '> RAB', lines[-1] } end + def test_transform + tmux.send_keys %{#{FZF} --bind 'focus:transform:echo "change-prompt({fzf:action})"'}, :Enter + tmux.until { |lines| assert_equal 'start', lines[-1] } + tmux.send_keys :Up + tmux.until { |lines| assert_equal 'up', lines[-1] } + end + def test_clear_selection tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter tmux.until { |lines| assert_equal 100, lines.match_count } -- cgit v1.2.3