summaryrefslogtreecommitdiffstats
path: root/default-plugins
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-03-25 15:41:08 +0100
committerGitHub <noreply@github.com>2022-03-25 15:41:08 +0100
commitb5cb5474bb9c6d05b702873c1eac4aca955f2968 (patch)
tree4ed90c12cb6558648e3ce63248e0c5c82a117b94 /default-plugins
parentbe02f99652d53e075872ee7f54baf267474e6596 (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')
-rw-r--r--default-plugins/tab-bar/src/main.rs14
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);
+ }
}
}