Skip to content

Commit 5e1cef4

Browse files
committed
fix ScrollPercent
1 parent eaff7e7 commit 5e1cef4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

viewport/viewport.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ func (m Model) PastBottom() bool {
8787

8888
// ScrollPercent returns the amount scrolled as a float between 0 and 1.
8989
func (m Model) ScrollPercent() float64 {
90-
if m.Height >= len(m.lines) {
90+
actualDisplayedLength := len(linesToActualDisplayedLines(m.lines, m.Width))
91+
92+
if m.Height >= actualDisplayedLength {
9193
return 1.0
9294
}
9395
y := float64(m.YOffset)
9496
h := float64(m.Height)
95-
t := float64(len(m.lines))
97+
t := float64(actualDisplayedLength)
9698
v := y / (t - h)
9799
return math.Max(0.0, math.Min(1.0, v))
98100
}

0 commit comments

Comments
 (0)