diff options
Diffstat (limited to 'core/Places.zig')
| -rw-r--r-- | core/Places.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/Places.zig b/core/Places.zig index 1c24e992..6c3ac9ab 100644 --- a/core/Places.zig +++ b/core/Places.zig @@ -561,9 +561,12 @@ pub fn goTo(set: *Places, tab: u16, pane: *Pane, i: usize, add: bool) void { } set.current = i; set.gen +%= 1; - const off = pane.scroll(); - if (t.cur_row < off or t.cur_row >= off + @as(i32, pane.rows)) - pane.scrollBy(t.cur_row - off - @divTrunc(@as(i32, pane.rows), 2)); + // Off the view, its row half the body's rows down (as zz). + const line: usize = @intCast(@max(0, t.cur_row)); + const row = panes.File.rowOf(tab, pane, line, @intCast(@max(0, t.cur_col))); + const body: i64 = panes.File.shownRows(tab, pane); + const on = if (panes.File.rowsTo(tab, pane, panes.File.top(tab, pane), line, @intCast(body))) |d| d + row else -1; + if (on < 0 or on >= body) panes.File.setTop(pane, panes.File.walkRows(tab, pane, .{ .line = line, .row = row }, -@divTrunc(body, 2)).to); t.show(tab); } @@ -634,7 +637,7 @@ pub fn restore(set: *Places, tab: u16, pane: *Pane) void { r.head = @min(r.head, f.content.len); } pane.body.setRanges(tab, f.content, set.snap, &.{}, set.snap_pri, set.snap_expl); - f.scroll = set.snap_scroll; + panes.File.setTop(pane, .{ .line = set.snap_scroll }); f.syntax_dirty = true; pane.hscroll = set.snap_hscroll; } |
