diff options
| -rw-r--r-- | core/File.zig | 14 | ||||
| -rw-r--r-- | core/body_layer.zig | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/File.zig b/core/File.zig index 51773c89..ceb6d03b 100644 --- a/core/File.zig +++ b/core/File.zig @@ -2356,6 +2356,20 @@ test "a caret deep in a long line scrolls the view sideways to it, measured from try std.testing.expectEqual(@as(i32, 0), pane.hscroll); } +test "a caret left of a view scrolled sideways is not drawn in the gutter" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + p.settings.wrap = false; + const pane = try p.setTestFile("short1 END_A_MARKER_WAY_OUT_RIGHT_padpadpadpadpadpadpadpadpadpadpad_TAIL\n"); + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + try std.testing.expect((try p.render(arena.allocator())).cursor != null); + // One wheel notch (4 columns) of the 7 the gutter is: the caret, at + // column 0, was drawn 3 columns into the gutter. + pane.hscroll = 4; + try std.testing.expect((try p.render(arena.allocator())).cursor == null); +} + test "undo and redo walk back and forth through every step of random edits, joined entries and all" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); diff --git a/core/body_layer.zig b/core/body_layer.zig index 7dc097ad..1582136c 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -512,7 +512,10 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane ) else ccol; - if (prow >= pane.tag_rows and cx >= 0 and prow < body_bottom and cx < tw) + // Left of a view scrolled sideways it is off the view, not + // in the gutter. + const left: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; + if (prow >= pane.tag_rows and cx >= left and prow < body_bottom and cx < tw) s.cursor = .{ .x = tx + @as(u16, @intCast(cx)), .y = body_y + @as(u16, @intCast(prow - pane.tag_rows)), .bar = pane.body.mode == .insert }; } } else if (pane.terminal != null) visible: { |
