Fix streaming filter mode by not running reader callback concurrently

Close #3728
This commit is contained in:
Junegunn Choi 2024-04-14 23:34:25 +09:00
parent e86b81bbf5
commit 3acb4ca90e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -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)