From ad01f380bd85a9aee962050f83e22c1ad8069145 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 9 Jul 2024 16:46:49 -0300 Subject: [PATCH] fix: improve line no --- ui/pager.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/pager.go b/ui/pager.go index 02a7b12..aec9c7e 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -196,14 +196,16 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) { } case "e": - l := int(math.Round(float64(m.viewport.TotalLineCount()) * m.viewport.ScrollPercent())) + lineno := int(math.RoundToEven(float64(m.viewport.TotalLineCount()) * m.viewport.ScrollPercent())) if m.viewport.AtTop() { - l = 0 + lineno = 0 } - if m.viewport.AtBottom() { - l = m.viewport.TotalLineCount() - } - return m, openEditor(m.currentDocument.localPath, l) + log.Info( + "opening editor", + "file", m.currentDocument.localPath, + "line", fmt.Sprintf("%d/%d", lineno, m.viewport.TotalLineCount()), + ) + return m, openEditor(m.currentDocument.localPath, lineno) case "c": // Copy using OSC 52