Skip to content

Commit 6403456

Browse files
committed
Move LocalPty onto the direct proxy
Fixes microsoft#186070
1 parent 2bd04a1 commit 6403456

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Emitter } from 'vs/base/common/event';
77
import { Disposable } from 'vs/base/common/lifecycle';
8-
import { IProcessDataEvent, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, IProcessReadyEvent, ILocalPtyService } from 'vs/platform/terminal/common/terminal';
8+
import { IProcessDataEvent, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, IProcessReadyEvent, IPtyService } from 'vs/platform/terminal/common/terminal';
99
import { URI } from 'vs/base/common/uri';
1010
import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
1111

@@ -46,48 +46,48 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
4646
constructor(
4747
readonly id: number,
4848
readonly shouldPersist: boolean,
49-
@ILocalPtyService private readonly _localPtyService: ILocalPtyService
49+
private readonly _proxy: IPtyService
5050
) {
5151
super();
5252
}
5353

5454
start(): Promise<ITerminalLaunchError | { injectedArgs: string[] } | undefined> {
55-
return this._localPtyService.start(this.id);
55+
return this._proxy.start(this.id);
5656
}
5757
detach(forcePersist?: boolean): Promise<void> {
58-
return this._localPtyService.detachFromProcess(this.id, forcePersist);
58+
return this._proxy.detachFromProcess(this.id, forcePersist);
5959
}
6060
shutdown(immediate: boolean): void {
61-
this._localPtyService.shutdown(this.id, immediate);
61+
this._proxy.shutdown(this.id, immediate);
6262
}
6363
async processBinary(data: string): Promise<void> {
6464
if (this._inReplay) {
6565
return;
6666
}
67-
return this._localPtyService.processBinary(this.id, data);
67+
return this._proxy.processBinary(this.id, data);
6868
}
6969
input(data: string): void {
7070
if (this._inReplay) {
7171
return;
7272
}
73-
this._localPtyService.input(this.id, data);
73+
this._proxy.input(this.id, data);
7474
}
7575
resize(cols: number, rows: number): void {
7676
if (this._inReplay || this._lastDimensions.cols === cols && this._lastDimensions.rows === rows) {
7777
return;
7878
}
7979
this._lastDimensions.cols = cols;
8080
this._lastDimensions.rows = rows;
81-
this._localPtyService.resize(this.id, cols, rows);
81+
this._proxy.resize(this.id, cols, rows);
8282
}
8383
async clearBuffer(): Promise<void> {
84-
this._localPtyService.clearBuffer?.(this.id);
84+
this._proxy.clearBuffer?.(this.id);
8585
}
8686
freePortKillProcess(port: string): Promise<{ port: string; processId: string }> {
87-
if (!this._localPtyService.freePortKillProcess) {
87+
if (!this._proxy.freePortKillProcess) {
8888
throw new Error('freePortKillProcess does not exist on the local pty service');
8989
}
90-
return this._localPtyService.freePortKillProcess(port);
90+
return this._proxy.freePortKillProcess(port);
9191
}
9292
async getInitialCwd(): Promise<string> {
9393
return this._properties.initialCwd;
@@ -96,23 +96,23 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
9696
return this._properties.cwd || this._properties.initialCwd;
9797
}
9898
async refreshProperty<T extends ProcessPropertyType>(type: T): Promise<IProcessPropertyMap[T]> {
99-
return this._localPtyService.refreshProperty(this.id, type);
99+
return this._proxy.refreshProperty(this.id, type);
100100
}
101101
async updateProperty<T extends ProcessPropertyType>(type: T, value: IProcessPropertyMap[T]): Promise<void> {
102-
return this._localPtyService.updateProperty(this.id, type, value);
102+
return this._proxy.updateProperty(this.id, type, value);
103103
}
104104
getLatency(): Promise<number> {
105105
// TODO: The idea here was to add the result plus the time it took to get the latency
106-
return this._localPtyService.getLatency(this.id);
106+
return this._proxy.getLatency(this.id);
107107
}
108108
acknowledgeDataEvent(charCount: number): void {
109109
if (this._inReplay) {
110110
return;
111111
}
112-
this._localPtyService.acknowledgeDataEvent(this.id, charCount);
112+
this._proxy.acknowledgeDataEvent(this.id, charCount);
113113
}
114114
setUnicodeVersion(version: '6' | '11'): Promise<void> {
115-
return this._localPtyService.setUnicodeVersion(this.id, version);
115+
return this._proxy.setUnicodeVersion(this.id, version);
116116
}
117117

118118
handleData(e: string | IProcessDataEvent) {
@@ -165,6 +165,6 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
165165
}
166166

167167
handleOrphanQuestion() {
168-
this._localPtyService.orphanQuestionReply(this.id);
168+
this._proxy.orphanQuestionReply(this.id);
169169
}
170170
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
6262
readonly onDidRequestDetach = this._onDidRequestDetach.event;
6363

6464
constructor(
65-
@IInstantiationService private readonly _instantiationService: IInstantiationService,
6665
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
6766
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
6867
@ITerminalLogService logService: ITerminalLogService,
@@ -190,15 +189,15 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
190189
const executableEnv = await this._shellEnvironmentService.getShellEnv();
191190
// TODO: Using _proxy here bypasses the lastPtyId tracking on the main process
192191
const id = await this._proxy.createProcess(shellLaunchConfig, cwd, cols, rows, unicodeVersion, env, executableEnv, options, shouldPersist, this._getWorkspaceId(), this._getWorkspaceName());
193-
const pty = this._instantiationService.createInstance(LocalPty, id, shouldPersist);
192+
const pty = new LocalPty(id, shouldPersist, this._proxy);
194193
this._ptys.set(id, pty);
195194
return pty;
196195
}
197196

198197
async attachToProcess(id: number): Promise<ITerminalChildProcess | undefined> {
199198
try {
200199
await this._proxy.attachToProcess(id);
201-
const pty = this._instantiationService.createInstance(LocalPty, id, true);
200+
const pty = new LocalPty(id, true, this._proxy);
202201
this._ptys.set(id, pty);
203202
return pty;
204203
} catch (e) {

0 commit comments

Comments
 (0)