Pager: fill empty space with newlines

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

View File

@ -127,7 +127,15 @@ func View(model boba.Model) string {
top := max(0, m.Y)
bottom := min(len(m.lines), m.Y+m.Height)
lines := m.lines[top:bottom]
return "\n" + strings.Join(lines, "\n")
// Fill emtpy space with newlines
extraLines := ""
if len(lines) < m.Height {
extraLines = strings.Repeat("\n", m.Height-len(lines))
}
s := strings.Join(lines, "\n") + extraLines
return s
}
// ETC