diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-04-14 23:34:25 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-04-14 23:34:25 +0900 |
commit | 3acb4ca90e1c5f92cafc9794383c1ae1eb754023 (patch) | |
tree | 7aa3eeb3fe815e6823f4cf662e59db022af31af7 | |
parent | e86b81bbf5c55344f4e29060b71eb1ab563296fe (diff) |
Fix streaming filter mode by not running reader callback concurrently
Close #3728
-rw-r--r-- | src/core.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core.go b/src/core.go index 8253c49e..3d84c733 100644 --- a/src/core.go +++ b/src/core.go @@ -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) |