mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-15 16:13:56 +00:00
terminal: saturate cursor subtraction in resizeCols
PageList.resize takes the .lt branch when columns shrink, which calls resizeWithoutReflow (mutating self.rows to the new smaller value) and then resizeCols with the original opts.cursor.y. When both axes shrink in one call and the cursor sits at or past the new bottom row, the expression `self.rows - c.y - 1` underflows and panics in safety builds. Use saturating subtraction; "remaining rows below cursor" is 0 once the cursor sits at or past the new bottom.
This commit is contained in:
@@ -1059,7 +1059,7 @@ fn resizeCols(
|
||||
break :cursor .{
|
||||
.tracked_pin = c.pin orelse try self.trackPin(p),
|
||||
.untrack = c.pin == null,
|
||||
.remaining_rows = self.rows - c.y - 1,
|
||||
.remaining_rows = self.rows -| (c.y + 1),
|
||||
.wrapped_rows = wrapped,
|
||||
};
|
||||
} else null;
|
||||
@@ -1192,7 +1192,7 @@ fn resizeCols(
|
||||
break :wrapped wrapped;
|
||||
};
|
||||
|
||||
const current = self.rows - active_pt.active.y - 1;
|
||||
const current = self.rows -| (active_pt.active.y + 1);
|
||||
|
||||
var req_rows = c.remaining_rows;
|
||||
req_rows -|= wrapped -| c.wrapped_rows;
|
||||
|
||||
Reference in New Issue
Block a user