diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-27 16:38:42 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-27 16:38:42 +0900 |
commit | ed57dcb924112192636260fb31d0db54352c517a (patch) | |
tree | c7a6e58cc6e92d32caa004a078c57eab8f7c09af /test | |
parent | 95c77bfb98eff07c63599bb02a58f73d6c143e62 (diff) |
Extend placeholder expression for multiple selections
Close #788
Diffstat (limited to 'test')
-rw-r--r-- | test/test_go.rb | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index cdd96d10..f730f256 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -879,7 +879,7 @@ class TestGoFZF < TestBase def test_execute_multi output = '/tmp/fzf-test-execute-multi' - opts = %[--multi --bind \\"alt-a:execute-multi(echo {}/{} >> #{output}; sync)\\"] + opts = %[--multi --bind \\"alt-a:execute-multi(echo {}/{+} >> #{output}; sync)\\"] writelines tempname, %w[foo'bar foo"bar foo$bar foobar] tmux.send_keys "cat #{tempname} | #{fzf opts}", :Enter tmux.until { |lines| lines[-2].include? '4/4' } @@ -902,6 +902,43 @@ class TestGoFZF < TestBase File.unlink output rescue nil end + def test_execute_plus_flag + output = tempname + ".tmp" + File.unlink output rescue nil + writelines tempname, ["foo bar", "123 456"] + + tmux.send_keys "cat #{tempname} | #{FZF} --multi --bind 'x:execute(echo {+}/{}/{+2}/{2} >> #{output})'", :Enter + + execute = lambda do + tmux.send_keys 'x', 'y' + tmux.until { |lines| lines[-2].include? '0/2' } + tmux.send_keys :BSpace + tmux.until { |lines| lines[-2].include? '2/2' } + end + + tmux.until { |lines| lines[-2].include? '2/2' } + execute.call + + tmux.send_keys :Up + tmux.send_keys :Tab + execute.call + + tmux.send_keys :Tab + execute.call + + tmux.send_keys :Enter + tmux.prepare + readonce + + assert_equal [ + %[foo bar/foo bar/bar/bar], + %[123 456/foo bar/456/bar], + %[123 456 foo bar/foo bar/456 bar/bar] + ], File.readlines(output).map(&:chomp) + rescue + File.unlink output rescue nil + end + def test_execute_shell # Custom script to use as $SHELL output = tempname + '.out' @@ -1198,7 +1235,7 @@ class TestGoFZF < TestBase end def test_preview - tmux.send_keys %[seq 1000 | sed s/^2$// | #{FZF} --preview 'sleep 0.2; echo {{}-{}}' --bind ?:toggle-preview], :Enter + tmux.send_keys %[seq 1000 | sed s/^2$// | #{FZF} -m --preview 'sleep 0.2; echo {{}-{+}}' --bind ?:toggle-preview], :Enter tmux.until { |lines| lines[1].include?(' {1-1}') } tmux.send_keys :Up tmux.until { |lines| lines[1].include?(' {-}') } @@ -1212,6 +1249,17 @@ class TestGoFZF < TestBase tmux.until { |lines| lines[-2].start_with? ' 28/1000' } tmux.send_keys 'foobar' tmux.until { |lines| !lines[1].include?('{') } + tmux.send_keys 'C-u' + tmux.until { |lines| lines.match_count == 1000 } + tmux.until { |lines| lines[1].include?(' {1-1}') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?(' {-1}') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?(' {3-1 }') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?(' {4-1 3}') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?(' {5-1 3 4}') } end def test_preview_hidden |