1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

fix "no pane" tab hang when two panes close at once

There was a race condition where we could leave the tab
active index pointing to the wrong pane.

That meant that the tab information computed by the gui
layer would see no panes marked as active, and thus would
end up with no active tab.

This commit fixes that by clamping the active index to
the number of panes.

refs: https://github.com/wez/wezterm/issues/2304
This commit is contained in:
Wez Furlong 2022-07-25 21:05:41 -07:00
parent 39adbb984d
commit 5e6ce47330
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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 {