Skip to content

Commit 72fb364

Browse files
committed
Fix pty host lazy spawning
Fixes microsoft#187076
1 parent 0c3fb42 commit 72fb364

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vs/platform/terminal/node/ptyHostService.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export class PtyHostService extends Disposable implements IPtyService {
4343
this._ensurePtyHost();
4444
return this.__proxy!;
4545
}
46+
/**
47+
* Get the proxy if it exists, otherwise undefined. This is used when calls are not needed to be
48+
* passed through to the pty host if it has not yet been spawned.
49+
*/
50+
private get _optionalProxy(): IPtyService | undefined {
51+
return this.__proxy;
52+
}
4653

4754
private _ensurePtyHost() {
4855
if (!this.__connection) {
@@ -105,8 +112,6 @@ export class PtyHostService extends Disposable implements IPtyService {
105112
// Start the pty host when a window requests a connection, if the starter has that capability.
106113
if (this._ptyHostStarter.onRequestConnection) {
107114
Event.once(this._ptyHostStarter.onRequestConnection)(() => this._ensurePtyHost());
108-
} else {
109-
this._ensurePtyHost();
110115
}
111116

112117
this._ptyHostStarter.onWillShutdown?.(() => this._wasQuitRequested = true);
@@ -228,13 +233,10 @@ export class PtyHostService extends Disposable implements IPtyService {
228233
return this._proxy.listProcesses();
229234
}
230235
async getPerformanceMarks(): Promise<performance.PerformanceMark[]> {
231-
if (!this.__proxy) {
232-
return [];
233-
}
234-
return this._proxy.getPerformanceMarks();
236+
return this._optionalProxy?.getPerformanceMarks() ?? [];
235237
}
236-
reduceConnectionGraceTime(): Promise<void> {
237-
return this._proxy.reduceConnectionGraceTime();
238+
async reduceConnectionGraceTime(): Promise<void> {
239+
return this._optionalProxy?.reduceConnectionGraceTime();
238240
}
239241
start(id: number): Promise<ITerminalLaunchError | { injectedArgs: string[] } | undefined> {
240242
return this._proxy.start(id);

0 commit comments

Comments
 (0)