diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2018-06-10 01:40:22 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2018-06-10 01:40:22 +0900 |
commit | 2c26f02f5ce263820a339595517152b70ed63b80 (patch) | |
tree | 2440ac305ef78bb9d96065ed61eda8aa7c146c08 /test | |
parent | af87650bc42ec8b821a3502857ca28692d6525d4 (diff) |
Improve preview window update events
- Update preview window even if there is no match for the query string
if any of the placeholder expressions evaluates to a non-empty string.
- Also, if the command template contains {q}, preview window will be
updated if the query string changes even though the focus remains on
the same item.
An example:
git log --oneline --color=always |
fzf --reverse --ansi --preview \
'[ -n {1} ] && git show --color=always {1} || git show --color=always {q}'
Close #1307
Diffstat (limited to 'test')
-rw-r--r-- | test/test_go.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index 3c487b4b..4f4f94e1 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -1355,6 +1355,35 @@ class TestGoFZF < TestBase tmux.until { |_| %w[1 2 3] == File.readlines(tempname).map(&:chomp) } end + def test_preview_flags + tmux.send_keys %(seq 10 | sed 's/^/:: /; s/$/ /' | + #{FZF} --multi --preview 'echo {{2}/{s2}/{+2}/{+s2}/{q}}'), :Enter + tmux.until { |lines| lines[1].include?('{1/1 /1/1 /}') } + tmux.send_keys '123' + tmux.until { |lines| lines[1].include?('{////123}') } + tmux.send_keys 'C-u', '1' + tmux.until { |lines| lines.match_count == 2 } + tmux.until { |lines| lines[1].include?('{1/1 /1/1 /1}') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?('{10/10 /1/1 /1}') } + tmux.send_keys :BTab + tmux.until { |lines| lines[1].include?('{10/10 /1 10/1 10 /1}') } + tmux.send_keys '2' + tmux.until { |lines| lines[1].include?('{//1 10/1 10 /12}') } + tmux.send_keys '3' + tmux.until { |lines| lines[1].include?('{//1 10/1 10 /123}') } + end + + def test_preview_q_no_match + tmux.send_keys %(: | #{FZF} --preview 'echo foo {q}'), :Enter + tmux.until { |lines| lines.match_count == 0 } + tmux.until { |lines| !lines[1].include?('foo') } + tmux.send_keys 'bar' + tmux.until { |lines| lines[1].include?('foo bar') } + tmux.send_keys 'C-u' + tmux.until { |lines| !lines[1].include?('foo') } + end + def test_no_clear tmux.send_keys "seq 10 | fzf --no-clear --inline-info --height 5 > #{tempname}", :Enter prompt = '> < 10/10' |