From f43a0271d2a8855c701f6bd8c950143122cff090 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 18 May 2020 20:17:30 -0400 Subject: [PATCH] Bugfix: scroll percentage could read higher than 100% ater a resize --- ui/ui.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/ui.go b/ui/ui.go index 6795020..89869a0 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -310,7 +310,13 @@ func statusBarView(m model) string { logo := glowLogoView(logoText) // Scroll percent - percentText := fmt.Sprintf(" %3.f%% ", m.pager.ScrollPercent()*100) + scrollPercent := m.pager.ScrollPercent() + if scrollPercent > 1.0 { + // Don't let read more than 100%, which could happen if we resize and + // the bottom of the page ends up in the middle of the window. + scrollPercent = 1.0 + } + percentText := fmt.Sprintf(" %3.f%% ", scrollPercent*100) percent := te.String(percentText). Foreground(statusBarFg.Color()). Background(statusBarBg.Color()).