From 430914371acd3fe46c31d7be900214e7ea03f657 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 6 Jul 2026 14:49:20 -0300 Subject: 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. --- src/pardes.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pardes.zig') 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| { -- cgit v1.3