assertions to save our bacon

This commit is contained in:
Mitchell Hashimoto
2022-08-08 14:03:14 -07:00
parent e4c8bbd394
commit 9493561159

View File

@ -444,6 +444,13 @@ pub fn copyRow(self: *Screen, dst: usize, src: usize) void {
/// This will trim data if the size is getting smaller. This will reflow the /// This will trim data if the size is getting smaller. This will reflow the
/// soft wrapped text. /// soft wrapped text.
pub fn resize(self: *Screen, alloc: Allocator, rows: usize, cols: usize) !void { pub fn resize(self: *Screen, alloc: Allocator, rows: usize, cols: usize) !void {
defer {
assert(self.cursor.x < self.cols);
assert(self.cursor.y < self.rows);
assert(self.rows == rows);
assert(self.cols == cols);
}
// If the rows increased, we alloc space for the new rows (w/ existing cols) // If the rows increased, we alloc space for the new rows (w/ existing cols)
// and move the viewport such that the bottom is in view. // and move the viewport such that the bottom is in view.
if (rows > self.rows) { if (rows > self.rows) {