Fix streaming filter mode by not running reader callback concurrently

Close #3728
pull/3729/head
Junegunn Choi 2 weeks ago
parent e86b81bbf5
commit 3acb4ca90e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -3,6 +3,7 @@ package fzf
import (
"fmt"
"sync"
"time"
"unsafe"
@ -164,14 +165,17 @@ func Run(opts *Options, version string, revision string) {
found := false
if streamingFilter {
slab := util.MakeSlab(slab16Size, slab32Size)
mutex := sync.Mutex{}
reader := NewReader(
func(runes []byte) bool {
item := Item{}
if chunkList.trans(&item, runes) {
mutex.Lock()
if result, _, _ := pattern.MatchItem(&item, false, slab); result != nil {
opts.Printer(item.text.ToString())
found = true
}
mutex.Unlock()
}
return false
}, eventBox, opts.ReadZero, false)

Loading…
Cancel
Save