diff --git a/docs/changelog.md b/docs/changelog.md index e8f3986fb..15597ca7f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -73,6 +73,7 @@ As features stabilize some brief notes about them will accumulate here. * [gui-startup](config/lua/gui-events/gui-startup.md) now passes a [SpawnCommand](config/lua/SpawnCommand.md) parameter representing the `wezterm start` command arguments. * Tab `x` button is no longer obscured by tab title text for long tab titles [#2269](https://github.com/wez/wezterm/issues/2269) * Cursor position could end up in the wrong place when rewrapping lines and the cursor was on the rewrap boundary [#2162](https://github.com/wez/wezterm/issues/2162) +* Two or more panes closing at the same time could result in their containing tab hanging and being stuck with "no pane" for a title [#2304](https://github.com/wez/wezterm/issues/2304) #### Updated * Bundled harfbuzz to 4.4.1 diff --git a/mux/src/tab.rs b/mux/src/tab.rs index 528b9d8bd..710325e82 100644 --- a/mux/src/tab.rs +++ b/mux/src/tab.rs @@ -1406,7 +1406,13 @@ impl Tab { } } } - *self.active.borrow_mut() = active_idx; + // Even though we try to adjust active_idx for a removed pane, + // we may end up with a value that is out of range in the case + // where two panes close in the span of the same call. + // We account for that and fix things up by clamping the + // active index to pane_index (which after the loop above + // now is the count of panes in this tab). + *self.active.borrow_mut() = active_idx.min(pane_index.saturating_sub(1)); } if !dead_panes.is_empty() && kill {