fix(gutter): prevent integer overlow if view top moves past file end in relative numbering mode

This commit is contained in:
CJ van den Berg 2025-02-11 09:58:26 +01:00
parent dbd8521bc2
commit 4dce4ad994
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -195,7 +195,7 @@ pub fn render_relative(self: *Self, theme: *const Widget.Theme) void {
var rows = self.view_rows; var rows = self.view_rows;
var diff_symbols = self.diff_symbols.items; var diff_symbols = self.diff_symbols.items;
while (rows > 0) : (rows -= 1) { while (rows > 0) : (rows -= 1) {
if (pos > self.lines - @as(u32, @intCast(row))) return; if (self.lines > @as(u32, @intCast(row)) and pos > self.lines - @as(u32, @intCast(row))) return;
self.plane.set_style(if (linenum == 0) theme.editor_gutter_active else theme.editor_gutter); self.plane.set_style(if (linenum == 0) theme.editor_gutter_active else theme.editor_gutter);
const val = @abs(if (linenum == 0) line else linenum); const val = @abs(if (linenum == 0) line else linenum);