Merge pull request #5926 from xtermjs/cursor/fix-flushsync-onwriteparsed-7a21
Fix flushSync() to fire onWriteParsed
This commit is contained in:
@@ -125,5 +125,20 @@ describe('WriteBuffer', () => {
|
||||
assert.deepEqual(stack, []);
|
||||
assert.deepEqual(cbStack, []);
|
||||
});
|
||||
it('flushSync fires onWriteParsed', () => {
|
||||
let parsed = 0;
|
||||
wb.onWriteParsed(() => parsed++);
|
||||
wb.write('a');
|
||||
wb.write('b');
|
||||
assert.equal(parsed, 0);
|
||||
wb.flushSync();
|
||||
assert.equal(parsed, 1);
|
||||
});
|
||||
it('flushSync with no pending writes does not fire onWriteParsed', () => {
|
||||
let parsed = 0;
|
||||
wb.onWriteParsed(() => parsed++);
|
||||
wb.flushSync();
|
||||
assert.equal(parsed, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,7 +71,9 @@ export class WriteBuffer extends Disposable {
|
||||
|
||||
// Process all pending chunks synchronously
|
||||
let chunk: string | Uint8Array | undefined;
|
||||
let didProcess = false;
|
||||
while (chunk = this._writeBuffer.shift()) {
|
||||
didProcess = true;
|
||||
this._action(chunk);
|
||||
const cb = this._callbacks.shift();
|
||||
if (cb) cb();
|
||||
@@ -84,6 +86,9 @@ export class WriteBuffer extends Disposable {
|
||||
this._callbacks.length = 0;
|
||||
|
||||
this._isSyncWriting = false;
|
||||
if (didProcess) {
|
||||
this._onWriteParsed.fire();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user