fix(tabs): dont panic when tab history is empty and closing tab (#990)
This commit is contained in:
parent
4496c4d4dc
commit
d5fe53ef57
1 changed files with 20 additions and 7 deletions
|
|
@ -237,8 +237,11 @@ impl Screen {
|
||||||
&mut self,
|
&mut self,
|
||||||
client_ids_and_mode_infos: Vec<(ClientId, ModeInfo)>,
|
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 {
|
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();
|
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
|
self.active_tab_indices
|
||||||
.insert(client_id, client_previous_tab);
|
.insert(client_id, client_previous_tab);
|
||||||
self.tabs
|
self.tabs
|
||||||
|
|
@ -246,6 +249,16 @@ impl Screen {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add_client(client_id, Some(client_mode_info));
|
.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(
|
fn move_clients_between_tabs(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue