mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
fix: add bounds checking to the selectedrow func (#351)
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user