From 2b725a4db5e973d7ce90d1ac0996dcfd3c3f0116 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 9 Dec 2019 21:32:58 +0900 Subject: Defer resetting multi-selection on reload --- src/core.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/core.go') diff --git a/src/core.go b/src/core.go index 985c177f..ff558497 100644 --- a/src/core.go +++ b/src/core.go @@ -224,12 +224,14 @@ func Run(opts *Options, revision string) { // Event coordination reading := true - clearCache := false + clearCache := util.Once(false) + clearSelection := util.Once(false) ticks := 0 var nextCommand *string restart := func(command string) { reading = true - clearCache = true + clearCache = util.Once(true) + clearSelection = util.Once(true) chunkList.Clear() header = make([]string, 0, opts.HeaderLines) go reader.restart(command) @@ -262,10 +264,10 @@ func Run(opts *Options, revision string) { snapshot, count := chunkList.Snapshot() terminal.UpdateCount(count, !reading, value.(*string)) if opts.Sync { - terminal.UpdateList(PassMerger(&snapshot, opts.Tac)) + opts.Sync = false + terminal.UpdateList(PassMerger(&snapshot, opts.Tac), false) } - matcher.Reset(snapshot, input(), false, !reading, sort, clearCache) - clearCache = false + matcher.Reset(snapshot, input(), false, !reading, sort, clearCache()) case EvtSearchNew: var command *string @@ -284,8 +286,7 @@ func Run(opts *Options, revision string) { break } snapshot, _ := chunkList.Snapshot() - matcher.Reset(snapshot, input(), true, !reading, sort, clearCache) - clearCache = false + matcher.Reset(snapshot, input(), true, !reading, sort, clearCache()) delay = false case EvtSearchProgress: @@ -327,7 +328,7 @@ func Run(opts *Options, revision string) { terminal.startChan <- true } } - terminal.UpdateList(val) + terminal.UpdateList(val, clearSelection()) } } } -- cgit v1.2.3