diff options
Diffstat (limited to 'core/look.zig')
| -rw-r--r-- | core/look.zig | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/core/look.zig b/core/look.zig index b240b6e2..f60b90f5 100644 --- a/core/look.zig +++ b/core/look.zig @@ -423,9 +423,7 @@ pub fn jumpResult(p: *Pardes, id: usize, row: usize) bool { rp.body.nsel = 0; rp.body.cur_row = r; rp.body.cur_pinned = true; - const off = rp.scroll(); - const last = off + @as(i32, rp.rows) - 1; - if (r < off) rp.scrollBy(r - off) else if (r > last) rp.scrollBy(r - last); + if (rp.file != null) panes.File.show(p.settings.tab, rp, r, 0, 0); var realbuf: [4096]u8 = undefined; const span = if (tr.commands) wholeRowSpan(ln) @@ -744,14 +742,9 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at_in: Spot, landing: enum { center, }; if (pane.file) |*f| { if (at.line > panes.File.nlines(p.gpa, f)) return; - if (landing == .center) { - // center, clamp at top; a text that fits is shown whole - const next = if (pane.textFits()) 0 else (at.line - 1) -| pane.rows / 2; - if (next != f.scroll) { - f.scroll = next; - f.syntax_dirty = true; - } - } + // centred (its first row of text half the body's rows down, as + // zz), clamped at the top; a text that fits is shown whole + if (landing == .center) panes.File.setTop(pane, if (pane.textFits()) .{ .line = 0 } else panes.File.walkRows(p.settings.tab, pane, .{ .line = at.line - 1, .row = panes.File.rowOf(p.settings.tab, pane, at.line - 1, 0) }, -@as(i64, pane.rows / 2)).to); } pane.body.cur_row = @intCast(at.line - 1); pane.body.cur_col = if (at.col > 0) @intCast(at.col - 1) else 0; @@ -2195,6 +2188,7 @@ test "Look on a diff: headers and a hunk line's prefix are the whole line, hover // Back to the diff, scrolled to its top again. p.view().active = 0; pane.file.?.scroll = 0; + pane.file.?.scroll_row = 0; p.sync(); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); @@ -2268,6 +2262,7 @@ test "a click, a 9P whole-line look and an empty event write-back take one expan for (points) |at| { p.view().active = 0; pane.file.?.scroll = 0; + pane.file.?.scroll_row = 0; pane.body.cur_row = 0; p.sync(); _ = frame.reset(.retain_capacity); @@ -2344,6 +2339,7 @@ test "every entry point to Look takes one expansion: a diff line and a file:12:5 pane.body.cur_col = case.col; pane.body.cur_pinned = true; pane.file.?.scroll = 0; + pane.file.?.scroll_row = 0; p.sync(); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); |
