From 424ea184aa34d3227b971f7c59a18be7ed110e31 Mon Sep 17 00:00:00 2001 From: Pyxels <39232833+Pyxels@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:53:16 +0100 Subject: [PATCH] fix(tab): focus largest pane instead of topmost When multiple Panes have the same x coord in a MoveTabOrFocus event that switches tabs, instead of picking the pane at the top to focus, choose the one biggest one. This ensures that in stacked layouts, the focused pane is opened again when moving, instead of always focusing the top pane. closes #3006 --- zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs index fee6f56754..de37fad30c 100644 --- a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs +++ b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs @@ -1039,14 +1039,14 @@ impl<'a> TiledPaneGrid<'a> { Direction::Left => { let x_comparison = a.x().cmp(&b.x()); match x_comparison { - Ordering::Equal => b.y().cmp(&a.y()), + Ordering::Equal => a.rows().cmp(&b.rows()).then(b.y().cmp(&a.y())), _ => x_comparison, } }, Direction::Right => { let x_comparison = b.x().cmp(&a.x()); match x_comparison { - Ordering::Equal => b.y().cmp(&a.y()), + Ordering::Equal => a.rows().cmp(&b.rows()).then(b.y().cmp(&a.y())), _ => x_comparison, } },