diff --git a/default-plugins/about/src/tips.rs b/default-plugins/about/src/tips.rs index 3a594e8d..3b339ea9 100644 --- a/default-plugins/about/src/tips.rs +++ b/default-plugins/about/src/tips.rs @@ -323,7 +323,7 @@ impl Page { } )), ActiveComponent::new(TextOrCustomRender::Text( - Text::new("Press TAB to go to Chagne Mode Behavior") + Text::new("Press TAB to go to Change Mode Behavior") .color_range(3, 6..=9) )), ActiveComponent::new(TextOrCustomRender::Text( diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index e8e30dd7..42df89a7 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -1799,7 +1799,9 @@ pub fn multiple_users_in_different_panes_and_same_tab() { name: "take snapshot after", instruction: |remote_terminal: RemoteTerminal| -> bool { let mut step_is_complete = false; - if remote_terminal.cursor_position_is(63, 2) && remote_terminal.status_bar_appears() + if remote_terminal.cursor_position_is(63, 2) + && remote_terminal.status_bar_appears() + && remote_terminal.snapshot_contains("LOCK") { // cursor is in the newly opened second pane step_is_complete = true; diff --git a/zellij-server/src/panes/tiled_panes/pane_resizer.rs b/zellij-server/src/panes/tiled_panes/pane_resizer.rs index 24d5df4f..506481d4 100644 --- a/zellij-server/src/panes/tiled_panes/pane_resizer.rs +++ b/zellij-server/src/panes/tiled_panes/pane_resizer.rs @@ -54,7 +54,10 @@ impl<'a> PaneResizer<'a> { let spans = self .discretize_spans(grid, space) .map_err(|err| anyhow!("{}", err))?; - self.apply_spans(spans)?; + + if self.is_layout_valid(&spans) { + self.apply_spans(spans)?; + } Ok(()) } @@ -128,6 +131,31 @@ impl<'a> PaneResizer<'a> { Ok(grid.into_iter().flatten().collect()) } + // HACK: This whole function is a bit of a hack — it's here to stop us from breaking the layout if we've been given + // a bad state to start with. If this function returns false, nothing is resized. + fn is_layout_valid(&self, spans: &[Span]) -> bool { + // If pane stacks are too tall to fit on the screen, abandon ship before the status bar gets caught up in + // any erroneous resizing... + for span in spans { + let pane_is_stacked = self + .panes + .borrow() + .get(&span.pid) + .unwrap() + .current_geom() + .is_stacked(); + if pane_is_stacked && span.direction == SplitDirection::Vertical { + let min_stack_height = StackedPanes::new(self.panes.clone()) + .min_stack_height(&span.pid) + .unwrap(); + if span.size.as_usize() < min_stack_height { + return false; + } + } + } + true + } + fn apply_spans(&mut self, spans: Vec) -> Result<()> { let err_context = || format!("Failed to apply spans"); let mut geoms_changed = false; diff --git a/zellij-server/src/panes/tiled_panes/stacked_panes.rs b/zellij-server/src/panes/tiled_panes/stacked_panes.rs index a8640489..8044b0b0 100644 --- a/zellij-server/src/panes/tiled_panes/stacked_panes.rs +++ b/zellij-server/src/panes/tiled_panes/stacked_panes.rs @@ -309,7 +309,7 @@ impl<'a> StackedPanes<'a> { Ok(()) } fn pane_is_one_liner(&self, id: &PaneId) -> Result { - let err_context = || format!("Cannot determin if pane is one liner or not"); + let err_context = || format!("Cannot determine if pane is one liner or not"); let panes = self.panes.borrow(); let pane_to_close = panes.get(id).with_context(err_context)?; Ok(pane_to_close.position_and_size().rows.is_fixed()) diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 4738a23f..67124be1 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -1157,10 +1157,7 @@ impl Layout { .or_else(|| default_layout_dir()) .and_then(|layout_dir| match std::fs::read_dir(layout_dir) { Ok(layout_files) => Some(layout_files), - Err(e) => { - log::error!("Failed to read layout dir: {:?}", e); - None - }, + Err(_) => None, }) .map(|layout_files| { let mut available_layouts = vec![];