diff options
author | Aram Drevekenin <aram@poor.dev> | 2022-03-25 15:41:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-25 15:41:08 +0100 |
commit | b5cb5474bb9c6d05b702873c1eac4aca955f2968 (patch) | |
tree | 4ed90c12cb6558648e3ce63248e0c5c82a117b94 /default-plugins/tab-bar/src/main.rs | |
parent | be02f99652d53e075872ee7f54baf267474e6596 (diff) |
fix(screen): crash in intermediate no-tabs state (#1272)
* fix(screen): log error instead of crashing in intermediate state with no active tabs
* style(fmt): rustfmt
Diffstat (limited to 'default-plugins/tab-bar/src/main.rs')
-rw-r--r-- | default-plugins/tab-bar/src/main.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 05f241bbb..2067af9d2 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -42,9 +42,13 @@ impl ZellijPlugin for State { match event { Event::ModeUpdate(mode_info) => self.mode_info = mode_info, Event::TabUpdate(tabs) => { - // tabs are indexed starting from 1 so we need to add 1 - self.active_tab_idx = tabs.iter().position(|t| t.active).unwrap() + 1; - self.tabs = tabs; + if let Some(active_tab_index) = tabs.iter().position(|t| t.active) { + // tabs are indexed starting from 1 so we need to add 1 + self.active_tab_idx = active_tab_index + 1; + self.tabs = tabs; + } else { + eprintln!("Could not find active tab."); + } } Event::Mouse(me) => match me { Mouse::LeftClick(_, col) => { @@ -59,7 +63,9 @@ impl ZellijPlugin for State { } _ => {} }, - _ => unimplemented!(), // FIXME: This should be unreachable, but this could be cleaner + _ => { + eprintln!("Got unrecognized event: {:?}", event); + } } } |