Fix exception on resize during write

Fixes #5588
This commit is contained in:
Daniel Imms
2026-01-08 18:03:42 -08:00
parent 729a670043
commit 16a13f8504
3 changed files with 28 additions and 2 deletions
+7
View File
@@ -264,6 +264,13 @@ export class Buffer implements IBuffer {
this._cols = newCols;
this._rows = newRows;
// Ensure the cursor position invariant: ybase + y must be within buffer bounds
// This can be violated during reflow or when shrinking rows
if (this.lines.length > 0) {
const maxY = Math.max(0, this.lines.length - this.ybase - 1);
this.y = Math.min(this.y, maxY);
}
this._memoryCleanupQueue.clear();
// schedule memory cleanup only, if more than 10% of the lines are affected
if (dirtyMemoryLines > 0.1 * this.lines.length) {