mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-25 02:06:19 +03:00
fix(tabs): dont panic when tab history is empty and closing tab (#990)
This commit is contained in:
parent
4496c4d4dc
commit
d5fe53ef57
@ -237,14 +237,27 @@ impl Screen {
|
||||
&mut self,
|
||||
client_ids_and_mode_infos: Vec<(ClientId, ModeInfo)>,
|
||||
) {
|
||||
// this will panic if there are no more tabs (ie. if self.tabs.is_empty() == true)
|
||||
for (client_id, client_mode_info) in client_ids_and_mode_infos {
|
||||
let client_previous_tab = self.tab_history.get_mut(&client_id).unwrap().pop().unwrap();
|
||||
self.active_tab_indices
|
||||
.insert(client_id, client_previous_tab);
|
||||
self.tabs
|
||||
.get_mut(&client_previous_tab)
|
||||
.unwrap()
|
||||
.add_client(client_id, Some(client_mode_info));
|
||||
let client_tab_history = self.tab_history.entry(client_id).or_insert_with(Vec::new);
|
||||
match client_tab_history.pop() {
|
||||
Some(client_previous_tab) => {
|
||||
self.active_tab_indices
|
||||
.insert(client_id, client_previous_tab);
|
||||
self.tabs
|
||||
.get_mut(&client_previous_tab)
|
||||
.unwrap()
|
||||
.add_client(client_id, Some(client_mode_info));
|
||||
}
|
||||
None => {
|
||||
let next_tab_index = *self.tabs.keys().next().unwrap();
|
||||
self.active_tab_indices.insert(client_id, next_tab_index);
|
||||
self.tabs
|
||||
.get_mut(&next_tab_index)
|
||||
.unwrap()
|
||||
.add_client(client_id, Some(client_mode_info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn move_clients_between_tabs(
|
||||
|
Loading…
Reference in New Issue
Block a user