summaryrefslogtreecommitdiff
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-06-24 17:05:53 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-06-24 17:05:53 +0900
commit5b5283378571cca88a993630db3307319d2cb56d (patch)
tree65ab3b3c2cc5b01b93be50e5400c3f466be596db /src/core.go
parent15257680948bda849747465ac4edf5e9d90f2a52 (diff)
downloadfzf-5b5283378571cca88a993630db3307319d2cb56d.tar.gz
Do not start the initial reader if 'reload*' is bound to 'start'
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core.go b/src/core.go
index 87629b78..caada27c 100644
--- a/src/core.go
+++ b/src/core.go
@@ -147,13 +147,20 @@ func Run(opts *Options) (int, error) {
executor := util.NewExecutor(opts.WithShell)
// Reader
+ reloadOnStart := opts.reloadOnStart()
streamingFilter := opts.Filter != nil && !sort && !opts.Tac && !opts.Sync
var reader *Reader
if !streamingFilter {
reader = NewReader(func(data []byte) bool {
return chunkList.Push(data)
}, eventBox, executor, opts.ReadZero, opts.Filter == nil)
- go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip)
+
+ if reloadOnStart {
+ // reload or reload-sync action is bound to 'start' event, no need to start the reader
+ eventBox.Set(EvtReadNone, nil)
+ } else {
+ go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip)
+ }
}
// Matcher
@@ -227,7 +234,8 @@ func Run(opts *Options) (int, error) {
}
// Synchronous search
- if opts.Sync {
+ sync := opts.Sync && !reloadOnStart
+ if sync {
eventBox.Unwatch(EvtReadNew)
eventBox.WaitFor(EvtReadFin)
}
@@ -247,7 +255,7 @@ func Run(opts *Options) (int, error) {
if heightUnknown {
maxFit, padHeight = terminal.MaxFitAndPad()
}
- deferred := opts.Select1 || opts.Exit0 || opts.Sync
+ deferred := opts.Select1 || opts.Exit0 || sync
go terminal.Loop()
if !deferred && !heightUnknown {
// Start right away
@@ -314,6 +322,9 @@ func Run(opts *Options) (int, error) {
err = quitSignal.err
stop = true
return
+ case EvtReadNone:
+ reading = false
+ terminal.UpdateCount(0, false, nil)
case EvtReadNew, EvtReadFin:
if evt == EvtReadFin && nextCommand != nil {
restart(*nextCommand, nextEnviron)