summaryrefslogtreecommitdiff
path: root/src/layout.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:44:45 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitd09c1c36e4d4e1bc57aa14f5ba4c6131b6111429 (patch)
tree62d8d68a486950118af23dc5f623dccc1824d00a /src/layout.zig
parentb4172e6bde69eb35648f173f4497054d1fb2e0fc (diff)
downloadpardes-d09c1c36e4d4e1bc57aa14f5ba4c6131b6111429.tar.gz
pardes-d09c1c36e4d4e1bc57aa14f5ba4c6131b6111429.zip
Focus on a closed pane goes to the pane that takes its place, never to the one focused before
Dogfood closed a pane in one column and focus jumped to another column, only because that pane was focused last. Now removePane decides for every route (Del, a ctl del, a command pane's end, a 9P remove, a stillborn scratch replaced): the pane that grew into the rows, or the scratch standing in an emptied column; removeColumn gives it to the pane level with it in the column that takes the width. Closing an unfocused pane leaves focus alone. The per-caller focus lines in Del and replaceStillborn are gone, and so is prevFocus. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/layout.zig')
-rw-r--r--src/layout.zig14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/layout.zig b/src/layout.zig
index 8e44f1d9..855a3eb9 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -1000,7 +1000,7 @@ pub fn splitColumn(p: *Pardes, source_id: usize, id: usize, before: bool) bool {
if (needs_rebase) old_weight *= 2;
if (id == source_id) {
if (p.col_n[source_col] <= 1) return false;
- absorbVWeight(p, id, null);
+ _ = absorbVWeight(p, id, null);
removePane(p, id);
} else if (findPane(p, id) != null) return false;
@@ -1041,9 +1041,11 @@ pub fn snapColWeights(p: *Pardes, c: usize) void {
/// Hand a closing pane's rows to `to`. With none named they go up: past any
/// results listing to the nearest pane above that is not one, or to the
/// pane below when the closing one is first in its column.
-pub fn absorbVWeight(p: *Pardes, id: usize, to: ?usize) void {
- const f = findPane(p, id) orelse return;
- if (p.col_n[f.col] <= 1) return;
+/// Give a closing pane's rows to `to`, or to the nearest document above it
+/// (the pane below for the top one); the pane that got them is returned.
+pub fn absorbVWeight(p: *Pardes, id: usize, to: ?usize) ?usize {
+ const f = findPane(p, id) orelse return null;
+ if (p.col_n[f.col] <= 1) return null;
snapColWeights(p, f.col);
var sib = to orelse if (f.idx > 0) p.col_panes[f.col][f.idx - 1] else p.col_panes[f.col][f.idx + 1];
var k = f.idx;
@@ -1051,7 +1053,9 @@ pub fn absorbVWeight(p: *Pardes, id: usize, to: ?usize) void {
sib = p.col_panes[f.col][k - 1];
if (p.panes[sib]) |pp| if (if (pp.file) |ff| panes.Output.fileTraits(ff.output).doc else true) break;
}
- if (p.panes[sib]) |s| s.vweight += @as(f32, @floatFromInt(@max(1, p.rects[id].h)));
+ const s = p.panes[sib] orelse return null;
+ s.vweight += @as(f32, @floatFromInt(@max(1, p.rects[id].h)));
+ return sib;
}
pub fn splitParent(p: *Pardes, want: usize) usize {