m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

Always execute preview command if {q} is in the template

Even when {q} is empty. Because, why not?

While this can be seen as a breaking change, there is an easy workaround
to keep the old behavior.

    # This will show // even when the query is empty
    : | fzf --preview 'echo /{q}/'

    # But if you don't want it,
    : | fzf --preview '[ -n {q} ] || exit; echo /{q}/'

Close #2759
This commit is contained in:
Junegunn Choi
2022-12-30 09:57:10 +09:00
parent 6c37177cf5
commit d649f5d826
4 changed files with 18 additions and 7 deletions

View File

@@ -1555,13 +1555,13 @@ class TestGoFZF < TestBase
end
def test_preview_q_no_match
tmux.send_keys %(: | #{FZF} --preview 'echo foo {q}'), :Enter
tmux.send_keys %(: | #{FZF} --preview 'echo foo {q} foo'), :Enter
tmux.until { |lines| assert_equal 0, lines.match_count }
tmux.until { |lines| refute_includes lines[1], ' foo ' }
tmux.until { |lines| assert_includes lines[1], ' foo foo' }
tmux.send_keys 'bar'
tmux.until { |lines| assert_includes lines[1], ' foo bar ' }
tmux.until { |lines| assert_includes lines[1], ' foo bar foo' }
tmux.send_keys 'C-u'
tmux.until { |lines| refute_includes lines[1], ' foo ' }
tmux.until { |lines| assert_includes lines[1], ' foo foo' }
end
def test_preview_q_no_match_with_initial_query