mirror of
https://github.com/charmbracelet/glow
synced 2024-12-13 05:32:32 +00:00
fix: improve line no
This commit is contained in:
parent
597e56bad4
commit
ad01f380bd
1 changed files with 8 additions and 6 deletions
14
ui/pager.go
14
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
|
||||
|
|
Loading…
Reference in a new issue