mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-07 17:44:05 -05:00
Focus terminal next when exiting
This change also consistently hides the terminal when exiting the final terminal. Fixes #8211
This commit is contained in:
@@ -58,6 +58,7 @@ export interface ITerminalService {
|
||||
focus(): TPromise<any>;
|
||||
focusNext(): TPromise<any>;
|
||||
focusPrevious(): TPromise<any>;
|
||||
hide(): TPromise<any>;
|
||||
runSelectedText(): TPromise<any>;
|
||||
setActiveTerminal(index: number): TPromise<any>;
|
||||
toggle(): TPromise<any>;
|
||||
|
||||
@@ -47,7 +47,8 @@ export class TerminalPanel extends Panel {
|
||||
if (!dimension) {
|
||||
return;
|
||||
}
|
||||
if (this.terminalInstances.length > 0) {
|
||||
let activeIndex = this.terminalService.getActiveTerminalIndex();
|
||||
if (activeIndex !== -1 && this.terminalInstances.length > 0) {
|
||||
this.terminalInstances[this.terminalService.getActiveTerminalIndex()].layout(dimension);
|
||||
}
|
||||
}
|
||||
@@ -152,11 +153,14 @@ export class TerminalPanel extends Panel {
|
||||
this.terminalInstances[index].dispose();
|
||||
this.terminalInstances.splice(index, 1);
|
||||
}
|
||||
if (this.terminalInstances.length === 0) {
|
||||
this.terminalService.toggle();
|
||||
} else {
|
||||
if (this.terminalInstances.length > 0) {
|
||||
this.setActiveTerminal(this.terminalService.getActiveTerminalIndex());
|
||||
}
|
||||
if (this.terminalInstances.length === 0) {
|
||||
this.terminalService.hide();
|
||||
} else {
|
||||
this.terminalService.focus();
|
||||
}
|
||||
}
|
||||
|
||||
private updateTheme(themeId?: string): void {
|
||||
@@ -202,8 +206,9 @@ export class TerminalPanel extends Panel {
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
if (this.terminalInstances.length > 0) {
|
||||
this.terminalInstances[this.terminalService.getActiveTerminalIndex()].focus(true);
|
||||
let activeIndex = this.terminalService.getActiveTerminalIndex();
|
||||
if (activeIndex !== -1 && this.terminalInstances.length > 0) {
|
||||
this.terminalInstances[activeIndex].focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,14 @@ export class TerminalService implements ITerminalService {
|
||||
return this.panelService.openPanel(TERMINAL_PANEL_ID, true);
|
||||
}
|
||||
|
||||
public hide(): TPromise<any> {
|
||||
const panel = this.panelService.getActivePanel();
|
||||
if (panel && panel.getId() === TERMINAL_PANEL_ID) {
|
||||
this.partService.setPanelHidden(true);
|
||||
}
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public createNew(): TPromise<any> {
|
||||
let self = this;
|
||||
return this.toggleAndGetTerminalPanel().then((terminalPanel) => {
|
||||
@@ -182,7 +190,7 @@ export class TerminalService implements ITerminalService {
|
||||
let wasActiveTerminal = (index === this.getActiveTerminalIndex());
|
||||
// Push active index back if the closed process was before the active process
|
||||
if (this.getActiveTerminalIndex() >= index) {
|
||||
this.activeTerminalIndex--;
|
||||
this.activeTerminalIndex = Math.max(0, this.activeTerminalIndex - 1);
|
||||
}
|
||||
this.terminalProcesses.splice(index, 1);
|
||||
this._onInstancesChanged.fire();
|
||||
|
||||
Reference in New Issue
Block a user