fix: improve line no

This commit is contained in:
Carlos Alexandro Becker 2024-07-09 16:46:49 -03:00
parent 597e56bad4
commit ad01f380bd
No known key found for this signature in database

View file

@ -196,14 +196,16 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) {
} }
case "e": 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() { if m.viewport.AtTop() {
l = 0 lineno = 0
} }
if m.viewport.AtBottom() { log.Info(
l = m.viewport.TotalLineCount() "opening editor",
} "file", m.currentDocument.localPath,
return m, openEditor(m.currentDocument.localPath, l) "line", fmt.Sprintf("%d/%d", lineno, m.viewport.TotalLineCount()),
)
return m, openEditor(m.currentDocument.localPath, lineno)
case "c": case "c":
// Copy using OSC 52 // Copy using OSC 52