From 0fba087aa13fe1a4a03af984d4f7e850629f61b4 Mon Sep 17 00:00:00 2001 From: Joseph Goulden Date: Thu, 12 Dec 2019 14:06:06 +0000 Subject: [PATCH] fix: panic in TUI table selected item. focus is zero indexed (#3169) --- src/bin/tui/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/tui/table.rs b/src/bin/tui/table.rs index a3a01de08..a165d3d7e 100644 --- a/src/bin/tui/table.rs +++ b/src/bin/tui/table.rs @@ -502,7 +502,7 @@ impl + 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 { - 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])