Fix various issues when the terminal was not open on launch

Fixes #11969
This commit is contained in:
Daniel Imms 2016-09-13 14:49:31 -07:00
parent fec1d6a426
commit b893f49164
4 changed files with 11 additions and 3 deletions

View file

@ -22,6 +22,7 @@
display: flex;
padding: 0 20px;
flex-grow: 1;
width: 100%;
}
.monaco-workbench .panel.integrated-terminal .terminal-wrapper {

View file

@ -38,6 +38,7 @@ export class TerminalInstance implements ITerminalInstance {
public get onTitleChanged(): Event<string> { return this._onTitleChanged.event; }
private isExiting: boolean = false;
private isVisible: boolean = false;
private toDispose: lifecycle.IDisposable[] = [];
private skipTerminalKeybindings: Keybinding[] = [];
private process: cp.ChildProcess;
@ -74,6 +75,7 @@ export class TerminalInstance implements ITerminalInstance {
throw new Error('The terminal instance has already been attached to a container');
}
this.container = container;
this.wrapperElement = document.createElement('div');
DOM.addClass(this.wrapperElement, 'terminal-wrapper');
this.xtermElement = document.createElement('div');
@ -139,6 +141,7 @@ export class TerminalInstance implements ITerminalInstance {
this.container.appendChild(this.wrapperElement);
this.layout(new Dimension(this.container.offsetWidth, this.container.offsetHeight));
this.setVisible(this.isVisible);
}
public copySelection(): void {
@ -195,7 +198,10 @@ export class TerminalInstance implements ITerminalInstance {
}
public setVisible(visible: boolean): void {
DOM.toggleClass(this.wrapperElement, 'active', visible);
this.isVisible = visible;
if (this.wrapperElement) {
DOM.toggleClass(this.wrapperElement, 'active', visible);
}
}
public scrollDown(): void {

View file

@ -72,6 +72,8 @@ export class TerminalPanel extends Panel {
this.updateTheme();
this.updateConfig();
// Force another layout (first is setContainers) since config has changed
this.layout(new Dimension(this.terminalContainer.offsetWidth, this.terminalContainer.offsetHeight));
return TPromise.as(void 0);
}

View file

@ -143,11 +143,11 @@ export class TerminalService implements ITerminalService {
}
public setContainers(panelContainer: Builder, terminalContainer: HTMLElement): void {
this._configHelper.panelContainer = panelContainer;
this.terminalContainer = terminalContainer;
this._terminalInstances.forEach(terminalInstance => {
terminalInstance.attachToElement(this.terminalContainer);
});
this._configHelper.panelContainer = panelContainer;
}
public showPanel(focus?: boolean): TPromise<void> {
@ -155,7 +155,6 @@ export class TerminalService implements ITerminalService {
let panel = this.panelService.getActivePanel();
if (!panel || panel.getId() !== TERMINAL_PANEL_ID) {
return this.panelService.openPanel(TERMINAL_PANEL_ID, focus).then(() => {
panel = this.panelService.getActivePanel();
if (focus) {
this.getActiveInstance().focus(true);
}