diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-05-27 15:43:31 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-05-27 15:51:04 +0900 |
commit | 4c70745cc1c8856486dab9e07985cbcf5081e490 (patch) | |
tree | 84a742cb75d32c13142a9354e4aa40858abc0f07 /src/core.go | |
parent | 7795748a3f42e86a802cc9ea9569429892f47f95 (diff) |
Fix bug where preview is not updated after reload when --disabled is set
Fix #3311
Diffstat (limited to 'src/core.go')
-rw-r--r-- | src/core.go | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/core.go b/src/core.go index e049fb43..e21e8c0a 100644 --- a/src/core.go +++ b/src/core.go @@ -138,7 +138,9 @@ func Run(opts *Options, version string, revision string) { opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos, opts.Filter == nil, opts.Nth, opts.Delimiter, runes) } - matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox) + inputRevision := 0 + snapshotRevision := 0 + matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox, inputRevision) // Filtering mode if opts.Filter != nil { @@ -209,8 +211,6 @@ func Run(opts *Options, version string, revision string) { // Event coordination reading := true - clearCache := util.Once(false) - clearSelection := util.Once(false) ticks := 0 var nextCommand *string eventBox.Watch(EvtReadNew) @@ -234,17 +234,17 @@ func Run(opts *Options, version string, revision string) { var count int restart := func(command string) { reading = true - clearCache = util.Once(true) - clearSelection = util.Once(true) chunkList.Clear() itemIndex = 0 + inputRevision++ header = make([]string, 0, opts.HeaderLines) go reader.restart(command) } for { delay := true ticks++ - input := func(reloaded bool) []rune { + input := func() []rune { + reloaded := snapshotRevision != inputRevision paused, input := terminal.Input() if reloaded && paused { query = []rune{} @@ -277,18 +277,18 @@ func Run(opts *Options, version string, revision string) { } if !useSnapshot { snapshot, count = chunkList.Snapshot() + snapshotRevision = inputRevision } total = count terminal.UpdateCount(total, !reading, value.(*string)) if opts.Sync { opts.Sync = false - terminal.UpdateList(PassMerger(&snapshot, opts.Tac), false) + terminal.UpdateList(PassMerger(&snapshot, opts.Tac, snapshotRevision)) } if heightUnknown && !deferred { determine(!reading) } - reset := !useSnapshot && clearCache() - matcher.Reset(snapshot, input(reset), false, !reading, sort, reset) + matcher.Reset(snapshot, input(), false, !reading, sort, snapshotRevision) case EvtSearchNew: var command *string @@ -313,17 +313,16 @@ func Run(opts *Options, version string, revision string) { if !changed { break } - reset := false if !useSnapshot { newSnapshot, _ := chunkList.Snapshot() // We want to avoid showing empty list when reload is triggered // and the query string is changed at the same time i.e. command != nil && changed if command == nil || len(newSnapshot) > 0 { snapshot = newSnapshot - reset = clearCache() + snapshotRevision = inputRevision } } - matcher.Reset(snapshot, input(reset), true, !reading, sort, reset) + matcher.Reset(snapshot, input(), true, !reading, sort, snapshotRevision) delay = false case EvtSearchProgress: @@ -363,7 +362,7 @@ func Run(opts *Options, version string, revision string) { determine(val.final) } } - terminal.UpdateList(val, clearSelection()) + terminal.UpdateList(val) } } } |