diff --git a/src/common/buffer/Buffer.ts b/src/common/buffer/Buffer.ts index 8c2b154b88..02ce7c8168 100644 --- a/src/common/buffer/Buffer.ts +++ b/src/common/buffer/Buffer.ts @@ -367,6 +367,11 @@ export class Buffer implements IBuffer { let srcCol = lastLineLength; while (srcLineIndex >= 0) { const cellsToCopy = Math.min(srcCol, destCol); + if (wrappedLines[destLineIndex] === undefined) { + // Sanity check that the line exists, this has been known to fail for an unknown reason + // which would stop the reflow from happening if an exception would throw. + break; + } wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true); destCol -= cellsToCopy; if (destCol === 0) {