diff --git a/docs/changelog.md b/docs/changelog.md index d43a4db5e..e23d619e8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -114,6 +114,7 @@ As features stabilize some brief notes about them will accumulate here. immediately with the default `exit_behavior` setting. Now ssh sessions override `exit_behavior="CloseOnCleanExit"` while connecting so that error information can be displayed. #3941 +* Divide by zero panic with lots of splits and resizing panes. #3921 #### Updated * Bundled harfbuzz to 8.0.0 diff --git a/mux/src/tab.rs b/mux/src/tab.rs index 1d9163182..324056c27 100644 --- a/mux/src/tab.rs +++ b/mux/src/tab.rs @@ -1177,8 +1177,14 @@ impl TabInner { } fn apply_pane_size(&mut self, pane_size: TerminalSize, cursor: &mut Cursor) { - let cell_width = pane_size.pixel_width / pane_size.cols; - let cell_height = pane_size.pixel_height / pane_size.rows; + let cell_width = pane_size + .pixel_width + .checked_div(pane_size.cols) + .unwrap_or(1); + let cell_height = pane_size + .pixel_height + .checked_div(pane_size.rows) + .unwrap_or(1); if let Ok(Some(node)) = cursor.node_mut() { // Adjust the size of the node; we preserve the size of the first // child and adjust the second, so if we are split down the middle