From a589be282670870dfbdb33cdb97cab02b17886e5 Mon Sep 17 00:00:00 2001 From: Alexey Kozy Date: Wed, 20 Aug 2025 13:47:40 -0700 Subject: [PATCH] fix: ensure that currentRow can not go out of the range --- src/browser/input/MoveToCell.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index c88db7b2..ce4c5922 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -199,7 +199,9 @@ function bufferLine( let currentRow = startRow; let bufferStr = ''; - while (currentCol !== endCol || currentRow !== endRow) { + while ((currentCol !== endCol || currentRow !== endRow) && + currentRow >= 0 && + currentRow < bufferService.buffer.lines.length) { currentCol += forward ? 1 : -1; if (forward && currentCol > bufferService.cols - 1) {