Skip to content

Commit 99e380d

Browse files
committed
Clean up RemotePty interface, use DI in remote backend
1 parent 31a5d12 commit 99e380d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
4242
private readonly _onRestoreCommands = this._register(new Emitter<ISerializedCommandDetectionCapability>());
4343
readonly onRestoreCommands = this._onRestoreCommands.event;
4444

45-
get id(): number { return this._id; }
46-
4745
constructor(
48-
private _id: number,
46+
readonly id: number,
4947
readonly shouldPersist: boolean,
5048
private readonly _remoteTerminalChannel: RemoteTerminalChannelClient,
51-
private readonly _remoteAgentService: IRemoteAgentService,
52-
private readonly _logService: ILogService
49+
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
50+
@ILogService private readonly _logService: ILogService
5351
) {
5452
super();
5553
this._startBarrier = new Barrier();
@@ -63,9 +61,9 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
6361
throw new Error('Could not fetch remote environment');
6462
}
6563

66-
this._logService.trace('Spawning remote agent process', { terminalId: this._id });
64+
this._logService.trace('Spawning remote agent process', { terminalId: this.id });
6765

68-
const startResult = await this._remoteTerminalChannel.start(this._id);
66+
const startResult = await this._remoteTerminalChannel.start(this.id);
6967

7068
if (startResult && 'message' in startResult) {
7169
// An error occurred
@@ -83,7 +81,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
8381

8482
shutdown(immediate: boolean): void {
8583
this._startBarrier.wait().then(_ => {
86-
this._remoteTerminalChannel.shutdown(this._id, immediate);
84+
this._remoteTerminalChannel.shutdown(this.id, immediate);
8785
});
8886
}
8987

@@ -93,7 +91,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
9391
}
9492

9593
this._startBarrier.wait().then(_ => {
96-
this._remoteTerminalChannel.input(this._id, data);
94+
this._remoteTerminalChannel.input(this.id, data);
9795
});
9896
}
9997

@@ -104,7 +102,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
104102
this._startBarrier.wait().then(_ => {
105103
this._lastDimensions.cols = cols;
106104
this._lastDimensions.rows = rows;
107-
this._remoteTerminalChannel.resize(this._id, cols, rows);
105+
this._remoteTerminalChannel.resize(this.id, cols, rows);
108106
});
109107
}
110108

@@ -126,12 +124,12 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
126124
}
127125

128126
this._startBarrier.wait().then(_ => {
129-
this._remoteTerminalChannel.acknowledgeDataEvent(this._id, charCount);
127+
this._remoteTerminalChannel.acknowledgeDataEvent(this.id, charCount);
130128
});
131129
}
132130

133131
async setUnicodeVersion(version: '6' | '11'): Promise<void> {
134-
return this._remoteTerminalChannel.setUnicodeVersion(this._id, version);
132+
return this._remoteTerminalChannel.setUnicodeVersion(this.id, version);
135133
}
136134

137135
async getInitialCwd(): Promise<string> {
@@ -143,11 +141,11 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
143141
}
144142

145143
async refreshProperty<T extends ProcessPropertyType>(type: T): Promise<IProcessPropertyMap[T]> {
146-
return this._remoteTerminalChannel.refreshProperty(this._id, type);
144+
return this._remoteTerminalChannel.refreshProperty(this.id, type);
147145
}
148146

149147
async updateProperty<T extends ProcessPropertyType>(type: T, value: IProcessPropertyMap[T]): Promise<void> {
150-
return this._remoteTerminalChannel.updateProperty(this._id, type, value);
148+
return this._remoteTerminalChannel.updateProperty(this.id, type, value);
151149
}
152150

153151
handleData(e: string | IProcessDataEvent) {
@@ -157,7 +155,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
157155
this._onProcessExit.fire(e);
158156
}
159157
processBinary(e: string): Promise<void> {
160-
return this._remoteTerminalChannel.processBinary(this._id, e);
158+
return this._remoteTerminalChannel.processBinary(this.id, e);
161159
}
162160
handleReady(e: IProcessReadyEvent) {
163161
this._onProcessReady.fire(e);
@@ -203,7 +201,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
203201
}
204202

205203
handleOrphanQuestion() {
206-
this._remoteTerminalChannel.orphanQuestionReply(this._id);
204+
this._remoteTerminalChannel.orphanQuestionReply(this.id);
207205
}
208206

209207
async getLatency(): Promise<number> {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
5757
readonly remoteAuthority: string | undefined,
5858
private readonly _remoteTerminalChannel: RemoteTerminalChannelClient,
5959
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
60+
@IInstantiationService private readonly _instantiationService: IInstantiationService,
6061
@ILogService logService: ILogService,
6162
@ICommandService private readonly _commandService: ICommandService,
6263
@IStorageService private readonly _storageService: IStorageService,
@@ -215,7 +216,7 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
215216
rows,
216217
unicodeVersion
217218
);
218-
const pty = new RemotePty(result.persistentTerminalId, shouldPersist, this._remoteTerminalChannel, this._remoteAgentService, this._logService);
219+
const pty = this._instantiationService.createInstance(RemotePty, result.persistentTerminalId, shouldPersist, this._remoteTerminalChannel);
219220
this._ptys.set(result.persistentTerminalId, pty);
220221
return pty;
221222
}
@@ -227,7 +228,7 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
227228

228229
try {
229230
await this._remoteTerminalChannel.attachToProcess(id);
230-
const pty = new RemotePty(id, true, this._remoteTerminalChannel, this._remoteAgentService, this._logService);
231+
const pty = this._instantiationService.createInstance(RemotePty, id, true, this._remoteTerminalChannel);
231232
this._ptys.set(id, pty);
232233
return pty;
233234
} catch (e) {

0 commit comments

Comments
 (0)