mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal: avoid underflow on resize, tests added
This commit is contained in:
@ -2170,7 +2170,7 @@ pub fn resize(self: *Screen, rows: usize, cols: usize) !void {
|
|||||||
// If the end of our copy is wide, we copy one less and
|
// If the end of our copy is wide, we copy one less and
|
||||||
// set the wide spacer header now since we're not going
|
// set the wide spacer header now since we're not going
|
||||||
// to write over it anyways.
|
// to write over it anyways.
|
||||||
if (wrapped_cells[wrapped_i + proposed - 1].cell.attrs.wide) {
|
if (proposed > 0 and wrapped_cells[wrapped_i + proposed - 1].cell.attrs.wide) {
|
||||||
proposed -= 1;
|
proposed -= 1;
|
||||||
new_row.getCellPtr(x + proposed).* = .{
|
new_row.getCellPtr(x + proposed).* = .{
|
||||||
.char = ' ',
|
.char = ' ',
|
||||||
@ -4842,6 +4842,18 @@ test "Screen: resize more cols no reflow" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/mitchellh/ghostty/issues/272#issuecomment-1676038963
|
||||||
|
test "Screen: resize more cols perfect split" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 3, 5, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
const str = "1ABCD2EFGH3IJKL";
|
||||||
|
try s.testWriteString(str);
|
||||||
|
try s.resize(3, 10);
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen: resize more cols trailing background colors" {
|
test "Screen: resize more cols trailing background colors" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user