Skip to content

Commit

Permalink
Merge pull request #173368 from rehmsen/terminal_welcome_view_switch
Browse files Browse the repository at this point in the history
Layout when switching from welcome to terminal.
  • Loading branch information
Tyriar authored Oct 31, 2023
2 parents 6384066 + 13df075 commit fb1c770
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class TerminalViewPane extends ViewPane {
private _parentDomElement: HTMLElement | undefined;
private _terminalTabbedView?: TerminalTabbedView;
get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; }
private _isWelcomeShowing: boolean = false;
private _isInitialized: boolean = false;
private _newDropdown: DropdownWithPrimaryActionViewItem | undefined;
private readonly _dropdownMenu: IMenu;
Expand Down Expand Up @@ -87,13 +86,18 @@ export class TerminalViewPane extends ViewPane {
}));

this._register(this._terminalService.onDidChangeInstances(() => {
if (!this._isWelcomeShowing) {
return;
// If the first terminal is opened, hide the welcome view
// and if the last one is closed, show it again
if (this._hasWelcomeScreen() && this._terminalService.instances.length <= 1) {
this._onDidChangeViewWelcomeState.fire();
}
this._isWelcomeShowing = true;
this._onDidChangeViewWelcomeState.fire();
if (!this._terminalTabbedView && this._parentDomElement) {
if (!this._parentDomElement) { return; }
// If we do not have the tab view yet, create it now.
if (!this._terminalTabbedView) {
this._createTabsView();
}
// If we just opened our first terminal, layout
if (this._terminalService.instances.length === 1) {
this.layoutBody(this._parentDomElement.offsetHeight, this._parentDomElement.offsetWidth);
}
}));
Expand Down Expand Up @@ -200,7 +204,7 @@ export class TerminalViewPane extends ViewPane {
this._register(this.onDidChangeBodyVisibility(async visible => {
this._viewShowing.set(visible);
if (visible) {
if (!this._terminalService.isProcessSupportRegistered) {
if (this._hasWelcomeScreen()) {
this._onDidChangeViewWelcomeState.fire();
}
this._initializeTerminal(false);
Expand Down Expand Up @@ -319,9 +323,12 @@ export class TerminalViewPane extends ViewPane {
}
}

private _hasWelcomeScreen(): boolean {
return !this._terminalService.isProcessSupportRegistered;
}

override shouldShowWelcome(): boolean {
this._isWelcomeShowing = !this._terminalService.isProcessSupportRegistered && this._terminalService.instances.length === 0;
return this._isWelcomeShowing;
return this._hasWelcomeScreen() && this._terminalService.instances.length === 0;
}
}

Expand Down

0 comments on commit fb1c770

Please sign in to comment.