fix(tiled-panes): recover from full stack (#4011)

This commit is contained in:
Aram Drevekenin 2025-02-21 12:16:39 +01:00 committed by GitHub
parent 6f8e9cc612
commit 2c8ef3b5b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -229,7 +229,7 @@ impl TiledPanes {
fn add_pane( fn add_pane(
&mut self, &mut self,
pane_id: PaneId, pane_id: PaneId,
mut pane: Box<dyn Pane>, pane: Box<dyn Pane>,
should_relayout: bool, should_relayout: bool,
client_id: Option<ClientId>, client_id: Option<ClientId>,
) { ) {
@ -245,6 +245,14 @@ impl TiledPanes {
return; return;
} }
} }
self.add_pane_without_stacked_resize(pane_id, pane, should_relayout)
}
fn add_pane_without_stacked_resize(
&mut self,
pane_id: PaneId,
mut pane: Box<dyn Pane>,
should_relayout: bool,
) {
let cursor_height_width_ratio = self.cursor_height_width_ratio(); let cursor_height_width_ratio = self.cursor_height_width_ratio();
let mut pane_grid = TiledPaneGrid::new( let mut pane_grid = TiledPaneGrid::new(
&mut self.panes, &mut self.panes,
@ -252,8 +260,6 @@ impl TiledPanes {
*self.display_area.borrow(), *self.display_area.borrow(),
*self.viewport.borrow(), *self.viewport.borrow(),
); );
// TODO: make sure this is really the same as the pre-stacked-resizes function... and
// behaves the same and all
let pane_id_and_split_direction = let pane_id_and_split_direction =
pane_grid.find_room_for_new_pane(cursor_height_width_ratio); pane_grid.find_room_for_new_pane(cursor_height_width_ratio);
match pane_id_and_split_direction { match pane_id_and_split_direction {
@ -317,8 +323,8 @@ impl TiledPanes {
self.set_force_render(); // TODO: why do we need this? self.set_force_render(); // TODO: why do we need this?
return; return;
}, },
Err(e) => { Err(_e) => {
log::error!("Failed to add pane to stack: {:?}", e); return self.add_pane_without_stacked_resize(pane_id, pane, should_relayout);
}, },
} }
} }