From 82f1c6a651588639d8ff1c27c4425b8801998713 Mon Sep 17 00:00:00 2001 From: Badr Date: Sun, 12 Jan 2025 20:06:48 +0100 Subject: [PATCH] handle case when metrics is empty --- oryx-tui/src/section/metrics.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oryx-tui/src/section/metrics.rs b/oryx-tui/src/section/metrics.rs index f432487..ae49ef9 100644 --- a/oryx-tui/src/section/metrics.rs +++ b/oryx-tui/src/section/metrics.rs @@ -200,6 +200,9 @@ impl Metrics { pub fn handle_keys(&mut self, key_event: KeyEvent) { match key_event.code { KeyCode::Char('d') => { + if self.metrics.is_empty() { + return; + } if let Some(selected_item_index) = &mut self.state.selected { self.terminate .store(true, std::sync::atomic::Ordering::Relaxed); @@ -234,6 +237,9 @@ impl Metrics { } KeyCode::Char('j') | KeyCode::Down => { + if self.metrics.is_empty() { + return; + } let i = match self.state.selected { Some(i) => { if i < self.window_height - 1 {