Skip to content

Commit

Permalink
fix(panes): handle various invalid state situations (#3776)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored Nov 15, 2024
1 parent 05fc91e commit f16ee08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions zellij-server/src/panes/tiled_panes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,9 @@ impl TiledPanes {
viewport_pane.reset_size_and_position_override();
}
self.panes_to_hide.clear();
let fullscreen_pane = self.get_pane_mut(fullscreen_pane_id).unwrap();
fullscreen_pane.reset_size_and_position_override();
if let Some(fullscreen_pane) = self.get_pane_mut(fullscreen_pane_id) {
fullscreen_pane.reset_size_and_position_override();
}
self.set_force_render();
let display_area = *self.display_area.borrow();
self.resize(display_area);
Expand Down
10 changes: 7 additions & 3 deletions zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<'a> TiledPaneGrid<'a> {
}

fn reduce_pane_height(&mut self, id: &PaneId, percent: f64) {
if self.can_reduce_pane_height(id, percent).unwrap() {
if self.can_reduce_pane_height(id, percent).unwrap_or(false) {
let current_pane_is_stacked = self
.panes
.borrow()
Expand Down Expand Up @@ -1292,7 +1292,9 @@ impl<'a> TiledPaneGrid<'a> {
// false => didn't succeed, so didn't do anything
let (freed_width, freed_height, pane_to_close_is_stacked) = {
let panes = self.panes.borrow_mut();
let pane_to_close = panes.get(&id).unwrap();
let Some(pane_to_close) = panes.get(&id) else {
return false;
};
let freed_space = pane_to_close.position_and_size();
let freed_width = freed_space.cols.as_percent();
let freed_height = freed_space.rows.as_percent();
Expand Down Expand Up @@ -1350,7 +1352,9 @@ impl<'a> TiledPaneGrid<'a> {
},
);
pane_id_to_split.and_then(|t_id_to_split| {
let pane_to_split = panes.get(t_id_to_split).unwrap();
let Some(pane_to_split) = panes.get(t_id_to_split) else {
return None;
};
let direction = if pane_to_split.rows()
* cursor_height_width_ratio.unwrap_or(DEFAULT_CURSOR_HEIGHT_WIDTH_RATIO)
> pane_to_split.cols()
Expand Down

0 comments on commit f16ee08

Please sign in to comment.