Skip to content

Commit

Permalink
Fix streaming filter mode by not running reader callback concurrently
Browse files Browse the repository at this point in the history
Close #3728
  • Loading branch information
junegunn committed Apr 14, 2024
1 parent e86b81b commit 3acb4ca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fzf

import (
"fmt"
"sync"
"time"
"unsafe"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3acb4ca

Please sign in to comment.