Skip to content

Commit

Permalink
Fix #59635
Browse files Browse the repository at this point in the history
  • Loading branch information
g-arjones committed Oct 9, 2018
1 parent 1358e90 commit 0ce9601
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._toDispose.push(terminalService.onInstanceRequestExtHostProcess(request => this._onTerminalRequestExtHostProcess(request)));
this._toDispose.push(terminalService.onActiveInstanceChanged(instance => this._onActiveTerminalChanged(instance ? instance.id : undefined)));
this._toDispose.push(terminalService.onInstanceTitleChanged(instance => this._onTitleChanged(instance.id, instance.title)));
this._toDispose.push(terminalService.onInstanceProcessLaunching(instance => this._onProcessLaunching(instance.id)));

// Set initial ext host state
this.terminalService.terminalInstances.forEach(t => {
Expand Down Expand Up @@ -167,6 +168,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._proxy.$acceptTerminalTitleChange(terminalId, name);
}

private _onProcessLaunching(terminalId: number): void {
this._proxy.$acceptTerminalProcessLaunching(terminalId);
}

private _onTerminalRendererInput(terminalId: number, data: string): void {
this._proxy.$acceptTerminalRendererInput(terminalId, data);
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ export interface ExtHostTerminalServiceShape {
$acceptTerminalProcessId(id: number, processId: number): void;
$acceptTerminalProcessData(id: number, data: string): void;
$acceptTerminalRendererInput(id: number, data: string): void;
$acceptTerminalProcessLaunching(id: number): void;
$acceptTerminalTitleChange(id: number, name: string): void;
$acceptTerminalRendererDimensions(id: number, cols: number, rows: number): void;
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, cols: number, rows: number): void;
Expand Down
22 changes: 15 additions & 7 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,7 @@ export class ExtHostTerminal extends BaseExtHostTerminal implements vscode.Termi
pid?: number
) {
super(proxy, id);
this._pidPromise = new Promise<number>(c => {
if (pid === RENDERER_NO_PROCESS_ID) {
c(undefined);
} else {
this._pidPromiseComplete = c;
}
});
this._createProcessIdPromise(pid);
}

public create(
Expand Down Expand Up @@ -138,6 +132,16 @@ export class ExtHostTerminal extends BaseExtHostTerminal implements vscode.Termi
this._queueApiRequest(this._proxy.$hide, []);
}

public _createProcessIdPromise(pid?: number): void {
this._pidPromise = new Promise<number>(c => {
if (pid === RENDERER_NO_PROCESS_ID) {
c(undefined);
} else {
this._pidPromiseComplete = c;
}
});
}

public _setProcessId(processId: number): void {
// The event may fire 2 times when the panel is restored
if (this._pidPromiseComplete) {
Expand Down Expand Up @@ -350,6 +354,10 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
this._performTerminalIdAction(id, terminal => terminal._setProcessId(processId));
}

public $acceptTerminalProcessLaunching(id: number): void {
this._performTerminalIdAction(id, terminal => terminal._createProcessIdPromise());
}

private _performTerminalIdAction(id: number, callback: (terminal: ExtHostTerminal) => void): void {
let terminal = this._getTerminalById(id);
if (terminal) {
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/parts/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface ITerminalService {
onTabDisposed: Event<ITerminalTab>;
onInstanceCreated: Event<ITerminalInstance>;
onInstanceDisposed: Event<ITerminalInstance>;
onInstanceProcessLaunching: Event<ITerminalInstance>;
onInstanceProcessIdReady: Event<ITerminalInstance>;
onInstanceDimensionsChanged: Event<ITerminalInstance>;
onInstanceRequestExtHostProcess: Event<ITerminalProcessExtHostRequest>;
Expand Down Expand Up @@ -319,6 +320,8 @@ export interface ITerminalInstance {

onFocused: Event<ITerminalInstance>;

onProcessLaunching: Event<ITerminalInstance>;

onProcessIdReady: Event<ITerminalInstance>;

onRequestExtHostProcess: Event<ITerminalInstance>;
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/parts/terminal/common/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export abstract class TerminalService implements ITerminalService {
public get onInstancesChanged(): Event<void> { return this._onInstancesChanged.event; }
protected readonly _onInstanceTitleChanged: Emitter<ITerminalInstance> = new Emitter<ITerminalInstance>();
public get onInstanceTitleChanged(): Event<ITerminalInstance> { return this._onInstanceTitleChanged.event; }
protected readonly _onInstanceProcessLaunching: Emitter<ITerminalInstance> = new Emitter<ITerminalInstance>();
public get onInstanceProcessLaunching(): Event<ITerminalInstance> { return this._onInstanceProcessLaunching.event; }
protected readonly _onActiveInstanceChanged: Emitter<ITerminalInstance> = new Emitter<ITerminalInstance>();
public get onActiveInstanceChanged(): Event<ITerminalInstance> { return this._onActiveInstanceChanged.event; }
protected readonly _onTabDisposed: Emitter<ITerminalTab> = new Emitter<ITerminalTab>();
Expand Down Expand Up @@ -278,6 +280,7 @@ export abstract class TerminalService implements ITerminalService {
instance.addDisposable(instance.onTitleChanged(this._onInstanceTitleChanged.fire, this._onInstanceTitleChanged));
instance.addDisposable(instance.onProcessIdReady(this._onInstanceProcessIdReady.fire, this._onInstanceProcessIdReady));
instance.addDisposable(instance.onDimensionsChanged(() => this._onInstanceDimensionsChanged.fire(instance)));
instance.addDisposable(instance.onProcessLaunching(() => this._onInstanceProcessLaunching.fire(instance)));
instance.addDisposable(instance.onFocus(this._onActiveInstanceChanged.fire, this._onActiveInstanceChanged));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export class TerminalInstance implements ITerminalInstance {
public get onProcessIdReady(): Event<ITerminalInstance> { return this._onProcessIdReady.event; }
private readonly _onTitleChanged: Emitter<ITerminalInstance> = new Emitter<ITerminalInstance>();
public get onTitleChanged(): Event<ITerminalInstance> { return this._onTitleChanged.event; }
private readonly _onProcessLaunching: Emitter<ITerminalInstance> = new Emitter<ITerminalInstance>();
public get onProcessLaunching(): Event<ITerminalInstance> { return this._onProcessLaunching.event; }
private readonly _onData: Emitter<string> = new Emitter<string>();
public get onData(): Event<string> { return this._onData.event; }
private readonly _onLineData: Emitter<string> = new Emitter<string>();
Expand Down Expand Up @@ -772,6 +774,8 @@ export class TerminalInstance implements ITerminalInstance {
this._processManager.onProcessExit(exitCode => this._onProcessExit(exitCode));
this._processManager.onProcessData(data => this._onData.fire(data));

this._onProcessLaunching.fire(this);

if (this._shellLaunchConfig.name) {
this.setTitle(this._shellLaunchConfig.name, false);
} else {
Expand Down

0 comments on commit 0ce9601

Please sign in to comment.