mirror of
https://github.com/charmbracelet/glow
synced 2024-12-14 14:12:27 +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":
|
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
|
||||||
|
|
Loading…
Reference in a new issue