Skip to content
Myr

Remove invalid 'result' event when using --sync option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When the search for the initial query doesn't finish immediately fzf would trigger an invalid 'result' event for an empty query. seq 100 | fzf --query 99 --bind result:accept --sync # Prints 99 seq 1000000 | fzf --query 99 --bind result:accept --sync # Should print 99, but fzf would print 1

authored by Junegunn Choi · committed by Junegunn Choi · parent f864f8b · Browse files · 3 files+5 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−6 removed

  • other:+5 added−6 removed

3 files+5 added−6 removed

modified:man/man1/fzf.1+1 added-1 removed
810 unmodified lines
811812.TP813.B "--sync"814Synchronous search for multi-staged filtering. If specified, fzf will launch815ncurses finder only after the input stream is complete.815the finder only after the input stream is complete.816817.RS818e.g. \fBfzf --multi | fzf --sync\fR819.RE
727 unmodified lines
modified:src/core.go+2 added-3 removed
296 unmodified lines
297 }298 total = count299 terminal.UpdateCount(total, !reading, value.(*string))300 if opts.Sync {301 opts.Sync = false302 terminal.UpdateList(PassMerger(&snapshot, opts.Tac, snapshotRevision))301 terminal.UpdateList(PassMerger(&snapshot, opts.Tac, snapshotRevision), false)302 }303 if heightUnknown && !deferred {304 determine(!reading)305 }
76 unmodified lines
382 }383 determine(val.final)384 }385 }387 terminal.UpdateList(val)386 terminal.UpdateList(val, true)387 }388 }389 }390 events.Clear()
9 unmodified lines
modified:src/terminal.go+2 added-2 removed
1065 unmodified lines
1066 }1067}10681069// UpdateList updates Merger to display the list1070func (t *Terminal) UpdateList(merger *Merger) {1070func (t *Terminal) UpdateList(merger *Merger, triggerResultEvent bool) {1071 t.mutex.Lock()1072 prevIndex := minItem.Index()1073 reset := t.revision != merger.Revision()1074 if !reset && t.track != trackDisabled {
42 unmodified lines
1117 if _, prs := t.keymap[one]; prs {1118 t.eventChan <- one1119 }1120 }1121 if t.hasResultActions {1121 if triggerResultEvent && t.hasResultActions {1122 t.eventChan <- tui.Result.AsEvent()1123 }1124 }1125 t.mutex.Unlock()
3155 unmodified lines