Skip to content

Commit 9bca7ce

Browse files
committed
emit Exit via propertyChanged
1 parent c264147 commit 9bca7ce

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/vs/workbench/api/browser/mainThreadTerminalService.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
1010
import { StopWatch } from 'vs/base/common/stopwatch';
1111
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1212
import { ILogService } from 'vs/platform/log/common/log';
13-
import { IProcessProperty, IShellLaunchConfig, IShellLaunchConfigDto, TerminalLocation, TitleEventSource } from 'vs/platform/terminal/common/terminal';
13+
import { IProcessProperty, IShellLaunchConfig, IShellLaunchConfigDto, ProcessPropertyType, TerminalLocation, TitleEventSource } from 'vs/platform/terminal/common/terminal';
1414
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
1515
import { ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroupService, ITerminalInstance, ITerminalInstanceService, ITerminalLink, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
1616
import { TerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy';
@@ -303,18 +303,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
303303
proxy.onRequestLatency(() => this._onRequestLatency(proxy.instanceId));
304304
}
305305

306-
public $sendProcessTitle(terminalId: number, title: string): void {
307-
// Since title events can only come from vscode.Pseudoterminals right now, these are routed
308-
// directly to the instance as API source events such that they will replace the initial
309-
// `name` property provided for the Pseudoterminal. If we support showing both Api and
310-
// Process titles at the same time we may want to pass this through as a Process source
311-
// event.
312-
const instance = this._terminalService.getInstanceFromId(terminalId);
313-
if (instance) {
314-
instance.refreshTabLabels(title, TitleEventSource.Api);
315-
}
316-
}
317-
318306
public $sendProcessData(terminalId: number, data: string): void {
319307
this._terminalProcessProxies.get(terminalId)?.emitData(data);
320308
}
@@ -324,13 +312,15 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
324312
}
325313

326314
public $sendProcessProperty(terminalId: number, property: IProcessProperty<any>): void {
315+
if (property.type === ProcessPropertyType.Title) {
316+
const instance = this._terminalService.getInstanceFromId(terminalId);
317+
if (instance) {
318+
instance.refreshTabLabels(property.value, TitleEventSource.Api);
319+
}
320+
}
327321
this._terminalProcessProxies.get(terminalId)?.emitProcessProperty(property);
328322
}
329323

330-
public $sendProcessExit(terminalId: number, exitCode: number | undefined): void {
331-
this._terminalProcessProxies.get(terminalId)?.emitExit(exitCode);
332-
}
333-
334324
private async _onRequestLatency(terminalId: number): Promise<void> {
335325
const COUNT = 2;
336326
let sum = 0;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal
1616
get capabilities(): ProcessCapability[] { return this._capabilities; }
1717
private readonly _onProcessData = this._register(new Emitter<string>());
1818
readonly onProcessData: Event<string> = this._onProcessData.event;
19-
private readonly _onProcessExit = this._register(new Emitter<number | undefined>());
20-
readonly onProcessExit: Event<number | undefined> = this._onProcessExit.event;
2119
private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>());
2220
get onProcessReady(): Event<IProcessReadyEvent> { return this._onProcessReady.event; }
2321

@@ -85,11 +83,14 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal
8583
case ProcessPropertyType.ResolvedShellLaunchConfig:
8684
this.emitResolvedShellLaunchConfig(value);
8785
break;
86+
case ProcessPropertyType.Exit:
87+
this.emitExit(value);
88+
break;
8889
}
8990
}
9091

9192
emitExit(exitCode: number | undefined): void {
92-
this._onProcessExit.fire(exitCode);
93+
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Exit, value: exitCode });
9394
this.dispose();
9495
}
9596

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ export interface ITerminalProcessExtHostProxy extends IDisposable {
341341
emitData(data: string): void;
342342
emitProcessProperty(property: IProcessProperty<any>): void;
343343
emitReady(pid: number, cwd: string): void;
344-
emitExit(exitCode: number | undefined): void;
345344
emitLatency(latency: number): void;
346345

347346
onInput: Event<string>;

0 commit comments

Comments
 (0)