@xterm/xterm 6.1.0-beta.271 → 6.1.0-beta.273

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.271",
4
+ "version": "6.1.0-beta.273",
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.20.0",
117
117
  "xterm-benchmark": "^0.3.2"
118
118
  },
119
- "commit": "1f054097f3968e38db34ba0ba03906c79108c9fd"
119
+ "commit": "564113e0531693458497f3bbcdce8f53ad12ba44"
120
120
  }
@@ -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.271';
9
+ export const XTERM_VERSION = '6.1.0-beta.273';
@@ -73,7 +73,9 @@ export interface IBufferLineStringCache {
73
73
  */
74
74
  export class BufferLine implements IBufferLine {
75
75
  protected _data: Uint32Array;
76
+ /** Sparse cache; only read when `IS_COMBINED_MASK` is set in `_data`. */
76
77
  protected _combined: {[index: number]: string} = {};
78
+ /** Sparse cache; only read when `HAS_EXTENDED` is set in `_data`. */
77
79
  protected _extendedAttrs: {[index: number]: IExtendedAttrs | undefined} = {};
78
80
  protected _stringCacheEntryRef: WeakRef<IBufferLineStringCacheEntry> | undefined;
79
81
  public length: number;
@@ -205,9 +207,15 @@ export class BufferLine implements IBufferLine {
205
207
  cell.bg = this._data[$startIndex + Cell.BG];
206
208
  if (cell.content & Content.IS_COMBINED_MASK) {
207
209
  cell.combinedData = this._combined[index];
210
+ } else {
211
+ cell.combinedData = '';
208
212
  }
209
213
  if (cell.bg & BgFlags.HAS_EXTENDED) {
210
214
  cell.extended = this._extendedAttrs[index]!;
215
+ } else {
216
+ // Do not mutate cell.extended in place: it may still reference this line's map entry from a
217
+ // prior loadCell into a reused CellData (e.g. $workCell during insert/delete).
218
+ cell.extended = DEFAULT_ATTR_DATA.extended.clone();
211
219
  }
212
220
  return cell;
213
221
  }
@@ -459,14 +467,7 @@ export class BufferLine implements IBufferLine {
459
467
  this._data.set(line._data);
460
468
  }
461
469
  this.length = line.length;
462
- this._combined = {};
463
- for (const el in line._combined) {
464
- this._combined[el] = line._combined[el];
465
- }
466
- this._extendedAttrs = {};
467
- for (const el in line._extendedAttrs) {
468
- this._extendedAttrs[el] = line._extendedAttrs[el];
469
- }
470
+ this._copySparseMapsFrom(line);
470
471
  this.isWrapped = line.isWrapped;
471
472
  }
472
473
 
@@ -475,12 +476,7 @@ export class BufferLine implements IBufferLine {
475
476
  const newLine = new BufferLine(this._stringCache, 0, undefined, false);
476
477
  newLine._data = new Uint32Array(this._data);
477
478
  newLine.length = this.length;
478
- for (const el in this._combined) {
479
- newLine._combined[el] = this._combined[el];
480
- }
481
- for (const el in this._extendedAttrs) {
482
- newLine._extendedAttrs[el] = this._extendedAttrs[el];
483
- }
479
+ newLine._copySparseMapsFrom(this);
484
480
  newLine.isWrapped = this.isWrapped;
485
481
  return newLine;
486
482
  }
@@ -511,27 +507,14 @@ export class BufferLine implements IBufferLine {
511
507
  for (let i = 0; i < Constants.CELL_INDICIES; i++) {
512
508
  this._data[(destCol + cell) * Constants.CELL_INDICIES + i] = srcData[(srcCol + cell) * Constants.CELL_INDICIES + i];
513
509
  }
514
- if (srcData[(srcCol + cell) * Constants.CELL_INDICIES + Cell.BG] & BgFlags.HAS_EXTENDED) {
515
- this._extendedAttrs[destCol + cell] = src._extendedAttrs[srcCol + cell];
516
- }
510
+ this._copyCellMapsFrom(src, srcCol + cell, destCol + cell);
517
511
  }
518
512
  } else {
519
513
  for (let cell = 0; cell < length; cell++) {
520
514
  for (let i = 0; i < Constants.CELL_INDICIES; i++) {
521
515
  this._data[(destCol + cell) * Constants.CELL_INDICIES + i] = srcData[(srcCol + cell) * Constants.CELL_INDICIES + i];
522
516
  }
523
- if (srcData[(srcCol + cell) * Constants.CELL_INDICIES + Cell.BG] & BgFlags.HAS_EXTENDED) {
524
- this._extendedAttrs[destCol + cell] = src._extendedAttrs[srcCol + cell];
525
- }
526
- }
527
- }
528
-
529
- // Move any combined data over as needed, FIXME: repeat for extended attrs
530
- const srcCombinedKeys = Object.keys(src._combined);
531
- for (let i = 0; i < srcCombinedKeys.length; i++) {
532
- const key = parseInt(srcCombinedKeys[i], 10);
533
- if (key >= srcCol) {
534
- this._combined[key - srcCol + destCol] = src._combined[key];
517
+ this._copyCellMapsFrom(src, srcCol + cell, destCol + cell);
535
518
  }
536
519
  }
537
520
  }
@@ -620,4 +603,24 @@ export class BufferLine implements IBufferLine {
620
603
  cacheEntry.isTrimmed = false;
621
604
  }
622
605
  }
606
+
607
+ /** Copy sparse map entries for a single cell when `_data` flags require them. */
608
+ private _copyCellMapsFrom(src: BufferLine, srcCol: number, destCol: number): void {
609
+ const srcStart = srcCol * Constants.CELL_INDICIES;
610
+ if (src._data[srcStart + Cell.CONTENT] & Content.IS_COMBINED_MASK) {
611
+ this._combined[destCol] = src._combined[srcCol];
612
+ }
613
+ if (src._data[srcStart + Cell.BG] & BgFlags.HAS_EXTENDED) {
614
+ this._extendedAttrs[destCol] = src._extendedAttrs[srcCol];
615
+ }
616
+ }
617
+
618
+ /** Rebuild sparse maps from another line, keyed only by `_data` flags. */
619
+ private _copySparseMapsFrom(line: BufferLine): void {
620
+ this._combined = {};
621
+ this._extendedAttrs = {};
622
+ for (let i = 0; i < line.length; i++) {
623
+ this._copyCellMapsFrom(line, i, i);
624
+ }
625
+ }
623
626
  }