@xterm/xterm 6.1.0-beta.94 → 6.1.0-beta.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xterm/xterm",
3
3
  "description": "Full xterm terminal, in your browser",
4
- "version": "6.1.0-beta.94",
4
+ "version": "6.1.0-beta.95",
5
5
  "main": "lib/xterm.js",
6
6
  "module": "lib/xterm.mjs",
7
7
  "style": "css/xterm.css",
@@ -116,5 +116,5 @@
116
116
  "ws": "^8.2.3",
117
117
  "xterm-benchmark": "^0.3.1"
118
118
  },
119
- "commit": "9bd128b315145f1ac66e4d61d3c68ba8e6dde59b"
119
+ "commit": "8112fbf21051938530491fc298fd8ffca56978c8"
120
120
  }
@@ -521,7 +521,13 @@ export class InputHandler extends Disposable implements IInputHandler {
521
521
  const wraparoundMode = this._coreService.decPrivateModes.wraparound;
522
522
  const insertMode = this._coreService.modes.insertMode;
523
523
  const curAttr = this._curAttrData;
524
- let bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!;
524
+ let bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y);
525
+
526
+ // Defensive check: bufferRow can be undefined if a resize occurred mid-write due to async
527
+ // scheduling gaps in WriteBuffer. See https://github.com/xtermjs/xterm.js/issues/5597
528
+ if (!bufferRow) {
529
+ return;
530
+ }
525
531
 
526
532
  this._dirtyRowTracker.markDirty(this._activeBuffer.y);
527
533
 
@@ -586,7 +592,10 @@ export class InputHandler extends Disposable implements IInputHandler {
586
592
  this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!.isWrapped = true;
587
593
  }
588
594
  // row changed, get it again
589
- bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!;
595
+ bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y);
596
+ if (!bufferRow) {
597
+ return;
598
+ }
590
599
  if (oldWidth > 0 && bufferRow instanceof BufferLine) {
591
600
  // Combining character widens 1 column to 2.
592
601
  // Move old character to next line.
@@ -6,4 +6,4 @@
6
6
  /**
7
7
  * The xterm.js version. This is updated by the publish script from package.json.
8
8
  */
9
- export const XTERM_VERSION = '6.1.0-beta.94';
9
+ export const XTERM_VERSION = '6.1.0-beta.95';
@@ -264,6 +264,13 @@ export class Buffer implements IBuffer {
264
264
  this._cols = newCols;
265
265
  this._rows = newRows;
266
266
 
267
+ // Ensure the cursor position invariant: ybase + y must be within buffer bounds
268
+ // This can be violated during reflow or when shrinking rows
269
+ if (this.lines.length > 0) {
270
+ const maxY = Math.max(0, this.lines.length - this.ybase - 1);
271
+ this.y = Math.min(this.y, maxY);
272
+ }
273
+
267
274
  this._memoryCleanupQueue.clear();
268
275
  // schedule memory cleanup only, if more than 10% of the lines are affected
269
276
  if (dirtyMemoryLines > 0.1 * this.lines.length) {