Skip to content

Commit

Permalink
fix: improve line no
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jul 9, 2024
1 parent 597e56b commit ad01f38
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ui/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad01f38

Please sign in to comment.