fix: panic in TUI table selected item. focus is zero indexed (#3169)

This commit is contained in:
Joseph Goulden 2019-12-12 14:06:06 +00:00 committed by Antioch Peverell
parent bde19777f0
commit 0fba087aa1

View file

@ -502,7 +502,7 @@ impl<T: TableViewItem<H> + PartialEq, H: Eq + Hash + Copy + Clone + 'static> Tab
/// Returns the index of the currently selected item within the underlying
/// storage vector.
pub fn item(&self) -> Option<usize> {
if self.items.is_empty() || self.focus > self.rows_to_items.len() {
if self.items.is_empty() || self.focus >= self.rows_to_items.len() {
None
} else {
Some(self.rows_to_items[self.focus])