summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-06 14:49:20 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit430914371acd3fe46c31d7be900214e7ea03f657 (patch)
tree83c8eae33356b068fa580c172180a308d5bc1bb5 /src/pardes.zig
parentde4def3548a6729b0dfd2120495a61beef8c8c2c (diff)
downloadpardes-430914371acd3fe46c31d7be900214e7ea03f657.tar.gz
pardes-430914371acd3fe46c31d7be900214e7ea03f657.zip
look on path:NN centers the target line in the pane body (scroll = line - body/2, clamped at 0): fresh opens lay out first (computeGeom after placeDoc) to center with the real body height; dedup re-looks recenter the existing pane. look-file golden shifts accordingly; new look-center snap proves fresh-open centering, dedup recentering, and the top clamp.
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index c4893b25..5b677250 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2631,7 +2631,7 @@ pub const Pardes = struct {
if (slot) |tt| if (tt.file) |*ff| if (std.mem.eql(u8, ff.path, target.path)) {
p.active = i;
if (target.line > 0 and target.line <= fileLineCount(ff.content)) {
- const next = target.line - 1;
+ const next = (target.line - 1) -| tt.rows / 2; // center, clamp at top
if (next != ff.scroll) {
ff.scroll = next;
ff.syntax_dirty = true;
@@ -2643,6 +2643,11 @@ pub const Pardes = struct {
const free = p.freeSlot() orelse return;
const nt = p.openFileView(free, target.path, target.line) catch return;
p.placeDoc(id, free, nt);
+ // center the target line: the pane's real body height only
+ // exists after placement, so lay out now and pull the
+ // scroll up by half a body (line 0 opens stay at the top)
+ p.computeGeom();
+ nt.file.?.scroll -|= @max(1, p.rects[free].h -| BOX_H) / 2;
},
.image => |target| {
for (p.panes, 0..) |slot, i| {