terminal: resize cols without reflow handles higher caps

This commit is contained in:
Mitchell Hashimoto
2024-03-11 20:13:45 -07:00
parent a2e97a86d0
commit 9137f52cbf
2 changed files with 25 additions and 6 deletions

View File

@ -581,7 +581,7 @@ fn resizeCols(
if (row.wrap) break :no_reflow;
}
try self.resizeWithoutReflowGrowCols(cap, chunk);
try self.resizeWithoutReflowGrowCols(cols, chunk);
continue;
}
@ -1245,11 +1245,9 @@ fn resizeWithoutReflow(self: *PageList, opts: Resize) !void {
// pages may not have the capacity for this. If they don't have
// the capacity we need to allocate a new page and copy the data.
.gt => {
const cap = try std_capacity.adjust(.{ .cols = cols });
var it = self.pageIterator(.right_down, .{ .screen = .{} }, null);
while (it.next()) |chunk| {
try self.resizeWithoutReflowGrowCols(cap, chunk);
try self.resizeWithoutReflowGrowCols(cols, chunk);
}
self.cols = cols;
@ -1260,11 +1258,12 @@ fn resizeWithoutReflow(self: *PageList, opts: Resize) !void {
fn resizeWithoutReflowGrowCols(
self: *PageList,
cap: Capacity,
cols: size.CellCountInt,
chunk: PageIterator.Chunk,
) !void {
assert(cap.cols > self.cols);
assert(cols > self.cols);
const page = &chunk.page.data;
const cap = try page.capacity.adjust(.{ .cols = cols });
// Update our col count
const old_cols = self.cols;

View File

@ -7708,6 +7708,26 @@ test "Terminal: resize with wraparound on" {
try testing.expectEqualStrings("01\n23", str);
}
test "Terminal: resize with high unique style per cell" {
const alloc = testing.allocator;
var t = try init(alloc, 30, 30);
defer t.deinit(alloc);
for (0..t.rows) |y| {
for (0..t.cols) |x| {
t.setCursorPos(y, x);
try t.setAttribute(.{ .direct_color_bg = .{
.r = @intCast(x),
.g = @intCast(y),
.b = 0,
} });
try t.print('x');
}
}
try t.resize(alloc, 60, 30);
}
test "Terminal: DECCOLM without DEC mode 40" {
const alloc = testing.allocator;
var t = try init(alloc, 5, 5);