diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-06 22:34:30 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-06 22:34:30 +0900 |
| commit | 1e6ac5590ec3c928b4d065a42eb45bac87752bbc (patch) | |
| tree | 1e50f12022b22340b1193067d5330ad2420744a9 /src | |
| parent | 5e42b1c9f8f61c3dd6165c1a9a8321e865a06601 (diff) | |
| download | fzf-1e6ac5590ec3c928b4d065a42eb45bac87752bbc.tar.gz | |
'reload' action should be allowed even where there's no match
If the command template doesn't have any placeholder expressions.
: | fzf --bind 'space:reload:seq 10'
Diffstat (limited to 'src')
| -rw-r--r-- | src/terminal.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/terminal.go b/src/terminal.go index 4cd507a3..3cd0af6e 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1237,7 +1237,7 @@ func parsePlaceholder(match string) (bool, string, placeholderFlags) { return false, matchWithoutFlags, flags } -func hasPreviewFlags(template string) (plus bool, query bool) { +func hasPreviewFlags(template string) (slot bool, plus bool, query bool) { for _, match := range placeholder.FindAllString(template, -1) { _, _, flags := parsePlaceholder(match) if flags.plus { @@ -1246,6 +1246,7 @@ func hasPreviewFlags(template string) (plus bool, query bool) { if flags.query { query = true } + slot = true } return } @@ -1409,7 +1410,7 @@ func (t *Terminal) currentItem() *Item { func (t *Terminal) buildPlusList(template string, forcePlus bool) (bool, []*Item) { current := t.currentItem() - plus, query := hasPreviewFlags(template) + _, plus, query := hasPreviewFlags(template) if !(query && len(t.input) > 0 || (forcePlus || plus) && len(t.selected) > 0) { return current != nil, []*Item{current, current} } @@ -2045,11 +2046,12 @@ func (t *Terminal) Loop() { t.failed = nil valid, list := t.buildPlusList(a.a, false) - // If the command template has {q}, we run the command even when the - // query string is empty. if !valid { - _, query := hasPreviewFlags(a.a) - valid = query + // We run the command even when there's no match + // 1. If the template doesn't have any slots + // 2. If the template has {q} + slot, _, query := hasPreviewFlags(a.a) + valid = !slot || query } if valid { command := replacePlaceholder(a.a, @@ -2095,7 +2097,7 @@ func (t *Terminal) Loop() { if queryChanged { if t.isPreviewEnabled() { - _, q := hasPreviewFlags(t.preview.command) + _, _, q := hasPreviewFlags(t.preview.command) if q { t.version++ } |
