Simplify terminal launch logic

This change goes away with the terminal launch delay (since the
dynamic xterm import does that) as well as waiting for the panel
to display. By doing so, this ensures that the TerminalInstance
is available when it's needed for the TerminalPanel to focus it
when clicking on the panel button.

Fixes #40416
This commit is contained in:
Daniel Imms 2018-06-11 18:49:06 +02:00
parent 08331720da
commit e0498489f3
2 changed files with 18 additions and 31 deletions

View file

@ -115,7 +115,7 @@ export class TerminalInstance implements ITerminalInstance {
@IThemeService private readonly _themeService: IThemeService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ILogService private _logService: ILogService,
@IStorageService private readonly _storageService: IStorageService,
@IStorageService private readonly _storageService: IStorageService
) {
this._disposables = [];
this._skipTerminalCommands = [];
@ -568,13 +568,15 @@ export class TerminalInstance implements ITerminalInstance {
}
public focus(force?: boolean): void {
if (!this._xterm) {
return;
}
const text = window.getSelection().toString();
if (!text || force) {
this._xterm.focus();
}
this._xtermReadyPromise.then(() => {
if (!this._xterm) {
return;
}
const text = window.getSelection().toString();
if (!text || force) {
this._xterm.focus();
}
});
}
public paste(): void {

View file

@ -25,7 +25,6 @@ import URI from 'vs/base/common/uri';
import { PANEL_BACKGROUND, PANEL_BORDER } from 'vs/workbench/common/theme';
import { TERMINAL_BACKGROUND_COLOR, TERMINAL_BORDER_COLOR } from 'vs/workbench/parts/terminal/common/terminalColorRegistry';
import { DataTransfers } from 'vs/base/browser/dnd';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
@ -45,7 +44,6 @@ export class TerminalPanel extends Panel {
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@ITerminalService private readonly _terminalService: ITerminalService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IThemeService protected themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@INotificationService private readonly _notificationService: INotificationService
@ -113,27 +111,14 @@ export class TerminalPanel extends Panel {
this._updateTheme();
} else {
return super.setVisible(visible).then(() => {
// Ensure the "Running" lifecycle face has been reached before creating the
// first terminal.
this._lifecycleService.when(LifecyclePhase.Running).then(() => {
// Allow time for the panel to display if it is being shown
// for the first time. If there is not wait here the initial
// dimensions of the pty could be wrong.
setTimeout(() => {
// Check if instances were already restored as part of workbench restore
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
return;
}
const instance = this._terminalService.createTerminal();
if (instance) {
this._updateFont();
this._updateTheme();
}
}, 0);
});
// Check if instances were already restored as part of workbench restore
if (this._terminalService.terminalInstances.length === 0) {
this._terminalService.createTerminal();
}
if (this._terminalService.terminalInstances.length > 0) {
this._updateFont();
this._updateTheme();
}
return TPromise.as(void 0);
});
}