Fix percentage artithmetic in pager

This commit is contained in:
Christian Rocha 2020-05-14 15:10:07 -04:00
parent 3960657824
commit 82e1aa81da
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ func (m Model) ScrollPercent() float64 {
y := float64(m.Y)
h := float64(m.Height)
t := float64(len(m.lines))
return (y + h) / t
return y / (t - h)
}
// Content set the pager's text content
@ -128,7 +128,7 @@ func View(model boba.Model) string {
bottom := min(len(m.lines), m.Y+m.Height)
lines := m.lines[top:bottom]
// Fill emtpy space with newlines
// Fill empty space with newlines
extraLines := ""
if len(lines) < m.Height {
extraLines = strings.Repeat("\n", m.Height-len(lines))