fix: rendering of line hightlight when cursor is off screen

This commit is contained in:
CJ van den Berg 2024-03-10 21:33:37 +01:00
parent 632ee5adf8
commit 6d3cf2df06

View file

@ -700,14 +700,17 @@ pub const Editor = struct {
} }
fn render_line_highlight(self: *const Self, cursor: *const Cursor, theme: *const Widget.Theme) !void { fn render_line_highlight(self: *const Self, cursor: *const Cursor, theme: *const Widget.Theme) !void {
if (self.screen_cursor(cursor)) |pos| { const row_min = self.view.row;
for (0..self.view.cols) |i| { const row_max = row_min + self.view.rows;
self.plane.cursor_move_yx(@intCast(pos.row), @intCast(i)) catch return; if (cursor.row < row_min or row_max < cursor.row)
var cell = self.plane.cell_init(); return;
_ = self.plane.at_cursor_cell(&cell) catch return; const row = cursor.row - self.view.row;
self.render_line_highlight_cell(theme, &cell); for (0..self.view.cols) |i| {
_ = self.plane.putc(&cell) catch {}; self.plane.cursor_move_yx(@intCast(row), @intCast(i)) catch return;
} var cell = self.plane.cell_init();
_ = self.plane.at_cursor_cell(&cell) catch return;
self.render_line_highlight_cell(theme, &cell);
_ = self.plane.putc(&cell) catch {};
} }
} }