From a2a7544a6f5c819c2ff067e3ef9b3475dfbb7a0a Mon Sep 17 00:00:00 2001 From: MrLuje Date: Sun, 12 Nov 2023 18:07:46 +0100 Subject: [PATCH] fix: trigger a single log refresh after changing 'since' (#2202) --- internal/view/log.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/internal/view/log.go b/internal/view/log.go index bf22e5b3..a5f9e343 100644 --- a/internal/view/log.go +++ b/internal/view/log.go @@ -33,15 +33,16 @@ const ( type Log struct { *tview.Flex - app *App - logs *Logger - indicator *LogIndicator - ansiWriter io.Writer - model *model.Log - cancelFn context.CancelFunc - cancelUpdates bool - mx sync.Mutex - follow bool + app *App + logs *Logger + indicator *LogIndicator + ansiWriter io.Writer + model *model.Log + cancelFn context.CancelFunc + cancelUpdates bool + mx sync.Mutex + follow bool + requestOneRefresh bool } var _ model.Component = (*Log)(nil) @@ -338,9 +339,12 @@ func (l *Log) Flush(lines [][]byte) { } }() - if len(lines) == 0 || !l.indicator.AutoScroll() || l.cancelUpdates { + if len(lines) == 0 || (!l.requestOneRefresh && !l.indicator.AutoScroll()) || l.cancelUpdates { return } + if l.requestOneRefresh { + l.requestOneRefresh = false + } for i := 0; i < len(lines); i++ { if l.cancelUpdates { break @@ -364,6 +368,7 @@ func (l *Log) sinceCmd(n int) func(evt *tcell.EventKey) *tcell.EventKey { } else { l.model.SetSinceSeconds(ctx, int64(n)) } + l.requestOneRefresh = true l.updateTitle() return nil