mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 07:47:23 +01:00
Fix chat terminal flicker during streaming (#298598)
This commit is contained in:
@@ -308,12 +308,10 @@ export class DetachedTerminalCommandMirror extends Disposable implements IDetach
|
|||||||
// if we blindly append.
|
// if we blindly append.
|
||||||
const canAppend = !!this._lastVT && vt.text.length >= this._lastVT.length && this._vtBoundaryMatches(vt.text, this._lastVT.length);
|
const canAppend = !!this._lastVT && vt.text.length >= this._lastVT.length && this._vtBoundaryMatches(vt.text, this._lastVT.length);
|
||||||
if (!canAppend) {
|
if (!canAppend) {
|
||||||
// Reset the terminal if we had previous content (can't append, need full rewrite)
|
// Use \x1bc (RIS) + new content in one write to avoid a blank frame
|
||||||
if (this._lastVT) {
|
const payload = this._lastVT ? `\x1bc${vt.text}` : vt.text;
|
||||||
detached.xterm.reset();
|
if (payload) {
|
||||||
}
|
detached.xterm.write(payload, resolve);
|
||||||
if (vt.text) {
|
|
||||||
detached.xterm.write(vt.text, resolve);
|
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
@@ -542,12 +540,10 @@ export class DetachedTerminalCommandMirror extends Disposable implements IDetach
|
|||||||
const canAppend = !!this._lastVT && startLine >= previousCursor && vt.text.length >= this._lastVT.length && this._vtBoundaryMatches(vt.text, this._lastVT.length);
|
const canAppend = !!this._lastVT && startLine >= previousCursor && vt.text.length >= this._lastVT.length && this._vtBoundaryMatches(vt.text, this._lastVT.length);
|
||||||
await new Promise<void>(resolve => {
|
await new Promise<void>(resolve => {
|
||||||
if (!canAppend) {
|
if (!canAppend) {
|
||||||
// Reset the terminal if we had previous content (can't append, need full rewrite)
|
// Use \x1bc (RIS) + new content in one write to avoid a blank frame
|
||||||
if (this._lastVT) {
|
const payload = this._lastVT ? `\x1bc${vt.text}` : vt.text;
|
||||||
detachedRaw.reset();
|
if (payload) {
|
||||||
}
|
detachedRaw.write(payload, resolve);
|
||||||
if (vt.text) {
|
|
||||||
detachedRaw.write(vt.text, resolve);
|
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,10 +261,8 @@ suite('Workbench - ChatTerminalCommandMirror', () => {
|
|||||||
// Boundary should NOT match because the prefix diverged
|
// Boundary should NOT match because the prefix diverged
|
||||||
strictEqual(boundaryMatches, false, 'Boundary check should detect divergence');
|
strictEqual(boundaryMatches, false, 'Boundary check should detect divergence');
|
||||||
|
|
||||||
// When boundary doesn't match, the fix does a full reset + rewrite
|
// Use \x1bc (RIS) + new content in one write to avoid a blank frame
|
||||||
// instead of corrupting the output by blind slicing
|
await write(mirror, `\x1bc${vt2}`);
|
||||||
mirror.raw.reset();
|
|
||||||
await write(mirror, vt2);
|
|
||||||
|
|
||||||
// Final content should be the complete new VT, not corrupted
|
// Final content should be the complete new VT, not corrupted
|
||||||
strictEqual(getBufferText(mirror), 'DifferentPrefixLine3');
|
strictEqual(getBufferText(mirror), 'DifferentPrefixLine3');
|
||||||
|
|||||||
Reference in New Issue
Block a user