Skip to content
Myr

Add `--sync` option

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

authored by Junegunn Choi · committed by Junegunn Choi · parent ff09c27 · Browse files · 5 files+37 added−15 removed
This commit

State

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

Diff stats

5 files+37 added−15 removed

  • other:+37 added−15 removed

5 files+37 added−15 removed

modified:src/util/eventbox.go+15 added
76 unmodified lines
77 for _, event := range events {78 b.ignore[event] = true79 }80}8182func (b *EventBox) WaitFor(event EventType) {83 looping := true84 for looping {85 b.Wait(func(events *Events) {86 for evt := range *events {87 switch evt {88 case event:89 looping = false90 return91 }92 }93 })94 }95}
modified:src/constants.go+1 added-1 removed
3 unmodified lines
4 "github.com/junegunn/fzf/src/util"5)67// Current version8const Version = "0.9.2"8const Version = "0.9.3"910// fzf events11const (12 EvtReadNew util.EventType = iota
6 unmodified lines
modified:src/core.go+7 added-12 removed
108 unmodified lines
109 patternString = opts.Query110 }111 pattern := patternBuilder([]rune(patternString))112113 looping := true113 eventBox.Unwatch(EvtReadNew)115 for looping {116 eventBox.Wait(func(events *util.Events) {117 for evt := range *events {118 switch evt {119 case EvtReadFin:120 looping = false121 return122 }123 }124 })125 }114 eventBox.WaitFor(EvtReadFin)115116 snapshot, _ := chunkList.Snapshot()117 merger, cancelled := matcher.scan(MatchRequest{118 chunks: snapshot,
11 unmodified lines
130 os.Exit(0)131 }132 }133134 // Synchronous search135 if opts.Sync {136 eventBox.Unwatch(EvtReadNew)137 eventBox.WaitFor(EvtReadFin)138 }139140 // Go interactive141 go matcher.Loop()142143 // Terminal I/O
48 unmodified lines
modified:src/options.go+11 added-1 removed
39 unmodified lines
40 -1, --select-1 Automatically select the only match41 -0, --exit-0 Exit immediately when there's no match42 -f, --filter=STR Filter mode. Do not start interactive finder.43 --print-query Print query as the first line44 --sync Synchronous search for multi-staged filtering45 (e.g. 'fzf --multi | fzf --sync')4647 Environment variables48 FZF_DEFAULT_COMMAND Default command to use when input is tty47 FZF_DEFAULT_OPTS Defaults options. (e.g. "-x -m")49 FZF_DEFAULT_OPTS Defaults options. (e.g. '-x -m')5051`5253// Mode denotes the current search mode
35 unmodified lines
89 Select1 bool90 Exit0 bool91 Filter *string92 PrintQuery bool93 Sync bool94 Version bool95}9697func defaultOptions() *Options {
15 unmodified lines
113 Select1: false,114 Exit0: false,115 Filter: nil,116 PrintQuery: false,117 Sync: false,118 Version: false}119}120121func help(ok int) {
125 unmodified lines
247 case "--no-print-query":248 opts.PrintQuery = false249 case "--prompt":250 opts.Prompt = nextString(allArgs, &i, "prompt string required")251 case "--sync":252 opts.Sync = true253 case "--no-sync":254 opts.Sync = false255 case "--async":256 opts.Sync = false257 case "--version":258 opts.Version = true259 default:260 if match, value := optString(arg, "-q|--query="); match {
43 unmodified lines
modified:README.md+3 added-1 removed
87 unmodified lines
88 -1, --select-1 Automatically select the only match89 -0, --exit-0 Exit immediately when there's no match90 -f, --filter=STR Filter mode. Do not start interactive finder.91 --print-query Print query as the first line92 --sync Synchronous search for multi-staged filtering93 (e.g. 'fzf --multi | fzf --sync')9495 Environment variables96 FZF_DEFAULT_COMMAND Default command to use when input is tty95 FZF_DEFAULT_OPTS Defaults options. (e.g. "-x -m")97 FZF_DEFAULT_OPTS Defaults options. (e.g. '-x -m')98```99100fzf will launch curses-based finder, read the list from STDIN, and write the101selected item to STDOUT.
445 unmodified lines