Skip to content
Myr

Merge branch '121-accept-nil-input' of https://github.com/dullgiulio/fzf into dullgiulio-121-accept-nil-input

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 · parents 0be4cea, f6dd320 · Browse files · 3 files+22 added−23 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+22 added−23 removed

  • other:+22 added−23 removed

3 files+22 added−23 removed

modified:src/core.go+2 added-2 removed
111 unmodified lines
112113 // Reader114 streamingFilter := opts.Filter != nil && !sort && !opts.Tac && !opts.Sync115 if !streamingFilter {116 reader := Reader{func(str string) { chunkList.Push(str) }, eventBox}116 reader := Reader{func(str string) { chunkList.Push(str) }, eventBox, opts.ReadZero}117 go reader.ReadSource()118 }119120 // Matcher
17 unmodified lines
138 item := chunkList.trans(&str, 0)139 if pattern.MatchItem(item) {140 fmt.Println(*item.text)141 }142 }, eventBox}142 }, eventBox, opts.ReadZero}143 reader.ReadSource()144 } else {145 eventBox.Unwatch(EvtReadNew)146 eventBox.WaitFor(EvtReadFin)
100 unmodified lines
modified:src/options.go+5 added
48 unmodified lines
49 -q, --query=STR Start the finder with the given query50 -1, --select-1 Automatically select the only match51 -0, --exit-0 Exit immediately when there's no match52 -f, --filter=STR Filter mode. Do not start interactive finder.53 --null Read null-byte separated strings from input54 --print-query Print query as the first line55 --expect=KEYS Comma-separated list of keys to complete fzf56 --sync Synchronous search for multi-staged filtering57
59 unmodified lines
117 ToggleSort bool118 Expect []int119 Keymap map[int]actionType120 PrintQuery bool121 ReadZero bool122 Sync bool123 Version bool124}125
30 unmodified lines
156 ToggleSort: false,157 Expect: []int{},158 Keymap: defaultKeymap(),159 PrintQuery: false,160 ReadZero: false,161 Sync: false,162 Version: false}163}164
362 unmodified lines
527 case "-0", "--exit-0":528 opts.Exit0 = true529 case "+0", "--no-exit-0":530 opts.Exit0 = false531 case "--null":532 opts.ReadZero = true533 case "--print-query":534 opts.PrintQuery = true535 case "--no-print-query":536 opts.PrintQuery = false
66 unmodified lines
modified:src/reader.go+15 added-21 removed
11 unmodified lines
12// Reader reads from command or standard input13type Reader struct {14 pusher func(string)15 eventBox *util.EventBox16 delimNil bool17}1819// ReadSource reads data from the default command or from standard input20func (r *Reader) ReadSource() {
9 unmodified lines
30 r.eventBox.Set(EvtReadFin, nil)31}3233func (r *Reader) feed(src io.Reader) {34 delim := byte('\n')35 if r.delimNil {36 delim = '\000'37 }38 reader := bufio.NewReader(src)34 eof := false35Loop:36 for !eof {37 buf := []byte{}38 iter := 0 // TODO: max size?39 for {40 // "ReadLine either returns a non-nil line or it returns an error, never both"41 line, isPrefix, err := reader.ReadLine()42 eof = err == io.EOF43 if eof {44 break45 } else if err != nil {46 break Loop39 for {40 line, err := reader.ReadString(delim)41 if line != "" {42 // "ReadString returns err != nil if and only if the returned data does not end in delim."43 if err == nil {44 line = line[:len(line)-1]45 }48 iter++49 buf = append(buf, line...)50 if !isPrefix {51 break52 }53 }54 if iter > 0 {55 r.pusher(string(buf))46 r.pusher(line)47 r.eventBox.Set(EvtReadNew, nil)48 }49 if err != nil {50 break51 }52 }53}5455func (r *Reader) readFromStdin() {
16 unmodified lines