fix: add bounds checking to the selectedrow func (#351)

This commit is contained in:
Mikael Fangel
2023-03-11 15:47:31 +01:00
committed by GitHub
parent 5db9f39f56
commit 7ba044773b
+4
View File
@@ -266,6 +266,10 @@ func (m *Model) UpdateViewport() {
// SelectedRow returns the selected row.
// You can cast it to your own implementation.
func (m Model) SelectedRow() Row {
if m.cursor < 0 || m.cursor >= len(m.rows) {
return nil
}
return m.rows[m.cursor]
}