Skip to content

Commit

Permalink
More aggressively clear viewport commands on Windows
Browse files Browse the repository at this point in the history
Fixes #198278
  • Loading branch information
Tyriar committed Feb 28, 2024
1 parent 145af9d commit 1ee4bfb
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ class WindowsPtyHeuristics extends Disposable {

private _onCursorMoveListener = this._register(new MutableDisposable());

private _recentlyPerformedCsiJ = false;

private _tryAdjustCommandStartMarkerScheduler?: RunOnceScheduler;
private _tryAdjustCommandStartMarkerScannedLineCount: number = 0;
private _tryAdjustCommandStartMarkerPollCount: number = 0;
Expand All @@ -530,20 +528,15 @@ class WindowsPtyHeuristics extends Disposable {
super();

this._register(_terminal.parser.registerCsiHandler({ final: 'J' }, params => {
// Clear commands when the viewport is cleared
if (params.length >= 1 && (params[0] === 2 || params[0] === 3)) {
this._recentlyPerformedCsiJ = true;
this._hooks.clearCommandsInViewport();
}
// We don't want to override xterm.js' default behavior, just augment it
return false;
}));

this._register(this._capability.onBeforeCommandFinished(command => {
if (this._recentlyPerformedCsiJ) {
this._recentlyPerformedCsiJ = false;
return;
}

// For older Windows backends we cannot listen to CSI J, instead we assume running clear
// or cls will clear all commands in the viewport. This is not perfect but it's right
// most of the time.
Expand Down

0 comments on commit 1ee4bfb

Please sign in to comment.