提交 65713437 编写于 作者: D Daniel Imms

Focus terminal next when exiting

This change also consistently hides the terminal when exiting the final
terminal.

Fixes #8211
上级 8657e6e2
......@@ -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,10 +153,13 @@ export class TerminalPanel extends Panel {
this.terminalInstances[index].dispose();
this.terminalInstances.splice(index, 1);
}
if (this.terminalInstances.length > 0) {
this.setActiveTerminal(this.terminalService.getActiveTerminalIndex());
}
if (this.terminalInstances.length === 0) {
this.terminalService.toggle();
this.terminalService.hide();
} else {
this.setActiveTerminal(this.terminalService.getActiveTerminalIndex());
this.terminalService.focus();
}
}
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册