From 9db31db8861563b871a8d1160140c5614993392c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 5 Jan 2026 11:10:56 -0800 Subject: [PATCH] Add undefined checks in erase calls This is likely a race condition during a resize which is hard to say what the right behavior is. Instead of hard failing by throwing an error, silently ignore if this happens. Fixes #5587 --- src/common/InputHandler.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 1dd1640f..e0e6253c 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -1154,7 +1154,10 @@ export class InputHandler extends Disposable implements IInputHandler { * @param respectProtect Whether to respect the protection attribute (DECSCA). */ private _eraseInBufferLine(y: number, start: number, end: number, clearWrap: boolean = false, respectProtect: boolean = false): void { - const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y); + if (!line) { + return; + } line.replaceCells( start, end, @@ -1224,7 +1227,10 @@ export class InputHandler extends Disposable implements IInputHandler { this._eraseInBufferLine(j, 0, this._activeBuffer.x + 1, true, respectProtect); if (this._activeBuffer.x + 1 >= this._bufferService.cols) { // Deleted entire previous line. This next line can no longer be wrapped. - this._activeBuffer.lines.get(j + 1)!.isWrapped = false; + const nextLine = this._activeBuffer.lines.get(j + 1); + if (nextLine) { + nextLine.isWrapped = false; + } } while (j--) { this._resetBufferLine(j, respectProtect);