Fix a potential out of bounds panic

This commit is contained in:
Christian Rocha 2020-06-19 19:46:51 -04:00
parent cc480dd2f3
commit 1cdc2045c7
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018

View File

@ -197,6 +197,10 @@ func (m *Model) LineUp(n int) (lines []string) {
// COMMANDS
func Sync(m Model) tea.Cmd {
if len(m.lines) == 0 {
return nil
}
top := max(m.YOffset, 0)
bottom := min(m.YOffset+m.Height, len(m.lines)-1)