1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

LibVT: Only resize the line after all rewrapping is done

Otherwise we would end up inserting empty cells into the wrapped lines.
Fixes #8227.
This commit is contained in:
Ali Mohammad Pur 2021-06-24 20:07:33 +04:30 committed by Andreas Kling
parent ffb118265b
commit 7c88caf99f
3 changed files with 36 additions and 21 deletions

View file

@ -1455,14 +1455,14 @@ void Terminal::set_size(u16 columns, u16 rows)
auto next_line = is_at_seam ? nullptr : &buffer[buffer.size() - i + 1];
auto& line = buffer[buffer.size() - i];
auto next_cursor = cursor_on_line(buffer.size() - i + 1);
line.set_length(columns, next_line, next_cursor ?: cursor_on_line(buffer.size() - i), !!next_cursor);
line.rewrap(columns, next_line, next_cursor ?: cursor_on_line(buffer.size() - i), !!next_cursor);
}
} else {
for (size_t i = 0; i < buffer.size(); ++i) {
auto is_at_seam = i + 1 == buffer.size();
auto next_line = is_at_seam ? nullptr : &buffer[i + 1];
auto next_cursor = cursor_on_line(i + 1);
buffer[i].set_length(columns, next_line, next_cursor ?: cursor_on_line(i), !!next_cursor);
buffer[i].rewrap(columns, next_line, next_cursor ?: cursor_on_line(i), !!next_cursor);
}
}
@ -1478,7 +1478,7 @@ void Terminal::set_size(u16 columns, u16 rows)
auto next_line = is_at_seam ? nullptr : &buffer[index + 1];
auto& line = buffer[index];
auto next_cursor = cursor_on_line(index + 1);
line.set_length(columns, next_line, next_cursor ?: cursor_on_line(index), !!next_cursor);
line.rewrap(columns, next_line, next_cursor ?: cursor_on_line(index), !!next_cursor);
if (line.length() > columns) {
auto current_cursor = cursor_on_line(index);
// Split the line into two (or more)
@ -1486,7 +1486,7 @@ void Terminal::set_size(u16 columns, u16 rows)
++rows_inserted;
buffer.insert(index, make<Line>(0));
VERIFY(buffer[index].length() == 0);
line.set_length(columns, &buffer[index], current_cursor, false);
line.rewrap(columns, &buffer[index], current_cursor, false);
// If we inserted a line and the old cursor was after that line, increment its row
if (!current_cursor && old_cursor.row >= index)
++old_cursor.row;
@ -1499,6 +1499,9 @@ void Terminal::set_size(u16 columns, u16 rows)
}
}
for (auto& line : buffer)
line.set_length(columns);
return old_cursor;
};