diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 7 |
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| { |
