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

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.95",
4
+ "version": "6.1.0-beta.96",
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": "8112fbf21051938530491fc298fd8ffca56978c8"
119
+ "commit": "49a8ac8fc00a1f5e90d96d1a29843209456a9e97"
120
120
  }
@@ -176,6 +176,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
176
176
  x = Math.max(x, MINIMUM_COLS);
177
177
  y = Math.max(y, MINIMUM_ROWS);
178
178
 
179
+ // Flush pending writes before resize to avoid race conditions where async
180
+ // writes are processed with incorrect dimensions
181
+ this._writeBuffer.flushSync();
182
+
179
183
  this._bufferService.resize(x, y);
180
184
  }
181
185
 
@@ -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.95';
9
+ export const XTERM_VERSION = '6.1.0-beta.96';
@@ -54,6 +54,38 @@ export class WriteBuffer extends Disposable {
54
54
  this._didUserInput = true;
55
55
  }
56
56
 
57
+ /**
58
+ * Flushes all pending writes synchronously. This is useful when you need to
59
+ * ensure all queued data is processed before performing an operation that
60
+ * depends upon everything being parsed like resize.
61
+ *
62
+ * Note: This is unreliable with async parser handlers as it does not wait for
63
+ * promises to resolve.
64
+ */
65
+ public flushSync(): void {
66
+ // exit early if another sync write loop is active
67
+ if (this._isSyncWriting) {
68
+ return;
69
+ }
70
+ this._isSyncWriting = true;
71
+
72
+ // Process all pending chunks synchronously
73
+ let chunk: string | Uint8Array | undefined;
74
+ while (chunk = this._writeBuffer.shift()) {
75
+ this._action(chunk);
76
+ const cb = this._callbacks.shift();
77
+ if (cb) cb();
78
+ }
79
+
80
+ // Reset buffer state
81
+ this._pendingData = 0;
82
+ this._bufferOffset = 0x7FFFFFFF;
83
+ this._writeBuffer.length = 0;
84
+ this._callbacks.length = 0;
85
+
86
+ this._isSyncWriting = false;
87
+ }
88
+
57
89
  /**
58
90
  * @deprecated Unreliable, to be removed soon.
59
91
  */