screen: adding cols doesn't mess with the viewport

This was untested anyways, and the result was bugs!
This commit is contained in:
Mitchell Hashimoto
2023-03-01 22:14:09 -08:00
parent 28378a350d
commit ba96a2c023

View File

@ -1947,13 +1947,6 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void {
if (copy_len == wrapped_cells_rem) { if (copy_len == wrapped_cells_rem) {
// If this row isn't also wrapped, we're done! // If this row isn't also wrapped, we're done!
if (!wrapped_row.header().flags.wrap) { if (!wrapped_row.header().flags.wrap) {
// If we were able to copy the entire row then
// we shortened the screen by one. We need to reflect
// this in our viewport.
if (wrapped_i == 0 and old.viewport > 0) {
old.viewport -= 1;
}
y += 1; y += 1;
break :wrapping; break :wrapping;
} }
@ -1981,12 +1974,6 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void {
} }
} }
// During the resize, we just keep the viewport at the bottom. But
// we want to restore the viewport to what the user had when they
// started the resize. old.viewport is maintained for removed lines
// in the for loop above.
self.viewport = old.viewport;
// If we have a new cursor, we need to convert that to a viewport // If we have a new cursor, we need to convert that to a viewport
// point and set it up. // point and set it up.
if (new_cursor) |pos| { if (new_cursor) |pos| {