Skip to content

Commit 31a5d12

Browse files
committed
Don't call PtyService.resize consecutively with the same values
1 parent e6881a3 commit 31a5d12

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

src/vs/workbench/contrib/terminal/browser/remotePty.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,8 @@ import { RemoteTerminalChannelClient } from 'vs/workbench/contrib/terminal/commo
1414
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
1515

1616
export class RemotePty extends Disposable implements ITerminalChildProcess {
17-
private readonly _onProcessData = this._register(new Emitter<string | IProcessDataEvent>());
18-
readonly onProcessData = this._onProcessData.event;
19-
private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>());
20-
readonly onProcessReady = this._onProcessReady.event;
21-
private readonly _onDidChangeProperty = this._register(new Emitter<IProcessProperty<any>>());
22-
readonly onDidChangeProperty = this._onDidChangeProperty.event;
23-
private readonly _onProcessExit = this._register(new Emitter<number | undefined>());
24-
readonly onProcessExit = this._onProcessExit.event;
25-
private readonly _onRestoreCommands = this._register(new Emitter<ISerializedCommandDetectionCapability>());
26-
readonly onRestoreCommands = this._onRestoreCommands.event;
27-
28-
private _startBarrier: Barrier;
29-
30-
private _inReplay = false;
31-
32-
private _properties: IProcessPropertyMap = {
17+
private readonly _startBarrier: Barrier;
18+
private readonly _properties: IProcessPropertyMap = {
3319
cwd: '',
3420
initialCwd: '',
3521
fixedDimensions: { cols: undefined, rows: undefined },
@@ -41,6 +27,20 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
4127
failedShellIntegrationActivation: false,
4228
usedShellIntegrationInjection: undefined
4329
};
30+
private readonly _lastDimensions: { cols: number; rows: number } = { cols: -1, rows: -1 };
31+
32+
private _inReplay = false;
33+
34+
private readonly _onProcessData = this._register(new Emitter<string | IProcessDataEvent>());
35+
readonly onProcessData = this._onProcessData.event;
36+
private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>());
37+
readonly onProcessReady = this._onProcessReady.event;
38+
private readonly _onDidChangeProperty = this._register(new Emitter<IProcessProperty<any>>());
39+
readonly onDidChangeProperty = this._onDidChangeProperty.event;
40+
private readonly _onProcessExit = this._register(new Emitter<number | undefined>());
41+
readonly onProcessExit = this._onProcessExit.event;
42+
private readonly _onRestoreCommands = this._register(new Emitter<ISerializedCommandDetectionCapability>());
43+
readonly onRestoreCommands = this._onRestoreCommands.event;
4444

4545
get id(): number { return this._id; }
4646

@@ -98,11 +98,12 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
9898
}
9999

100100
resize(cols: number, rows: number): void {
101-
if (this._inReplay) {
101+
if (this._inReplay || this._lastDimensions.cols === cols && this._lastDimensions.rows === rows) {
102102
return;
103103
}
104104
this._startBarrier.wait().then(_ => {
105-
105+
this._lastDimensions.cols = cols;
106+
this._lastDimensions.rows = rows;
106107
this._remoteTerminalChannel.resize(this._id, cols, rows);
107108
});
108109
}

src/vs/workbench/contrib/terminal/electron-sandbox/localPty.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability } fro
1414
* created on the local pty host.
1515
*/
1616
export class LocalPty extends Disposable implements ITerminalChildProcess {
17-
private _inReplay = false;
18-
private _properties: IProcessPropertyMap = {
17+
private readonly _properties: IProcessPropertyMap = {
1918
cwd: '',
2019
initialCwd: '',
2120
fixedDimensions: { cols: undefined, rows: undefined },
@@ -27,6 +26,10 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
2726
failedShellIntegrationActivation: false,
2827
usedShellIntegrationInjection: undefined
2928
};
29+
private readonly _lastDimensions: { cols: number; rows: number } = { cols: -1, rows: -1 };
30+
31+
private _inReplay = false;
32+
3033
private readonly _onProcessData = this._register(new Emitter<IProcessDataEvent | string>());
3134
readonly onProcessData = this._onProcessData.event;
3235
private readonly _onProcessReplay = this._register(new Emitter<IPtyHostProcessReplayEvent>());
@@ -70,9 +73,11 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
7073
this._localPtyService.input(this.id, data);
7174
}
7275
resize(cols: number, rows: number): void {
73-
if (this._inReplay) {
76+
if (this._inReplay || this._lastDimensions.cols === cols && this._lastDimensions.rows === rows) {
7477
return;
7578
}
79+
this._lastDimensions.cols = cols;
80+
this._lastDimensions.rows = rows;
7681
this._localPtyService.resize(this.id, cols, rows);
7782
}
7883
async clearBuffer(): Promise<void> {

0 commit comments

Comments
 (0)