diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-25 23:43:46 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-26 00:14:05 +0900 |
commit | 1707b8cdba42492a88b3fc43c15c20d219c5ce2b (patch) | |
tree | 268e6950fecc4bec86b38389101e52901134b3a5 /test | |
parent | 41d4d70b985f665c8ecc66b83aa10209c8dfbbfd (diff) |
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
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_go.rb | 7 |
1 files changed, 7 insertions, 0 deletions
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 } |