From 6896254c1240bab3e7ab3c9028039f3fd2c2b4c9 Mon Sep 17 00:00:00 2001 From: Benjamin Christopher Simmonds <44439583+benibenj@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:33:15 +0200 Subject: [PATCH] Show Sidebar in new Window when Activity Bar not default (#227677) --- src/vs/workbench/browser/layout.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 01a8e9e8981e3..aa0325898be90 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -671,6 +671,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi runtime: layoutRuntimeState, }; + const isNewWindow = lifecycleService.startupKind === StartupKind.NewWindow; + const activityBarNotDefault = this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) !== ActivityBarPosition.DEFAULT; + // Sidebar View Container To Restore if (this.isVisible(Parts.SIDEBAR_PART)) { @@ -692,6 +695,15 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this.stateModel.setRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN, true); } } + // Side bar is hidden and a new window is opened with activity bar not visible (not default) + else if (isNewWindow && activityBarNotDefault) { + // Open side bar if there is a view container to restore + const viewContainerToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE, this.viewDescriptorService.getDefaultViewContainer(ViewContainerLocation.Sidebar)?.id); + if (viewContainerToRestore) { + this.state.initialization.views.containerToRestore.sideBar = viewContainerToRestore; + this.stateModel.setRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN, false); + } + } // Panel View Container To Restore if (this.isVisible(Parts.PANEL_PART)) { @@ -705,13 +717,16 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } // Auxiliary Panel to restore - if (this.isVisible(Parts.AUXILIARYBAR_PART)) { + const auxiliaryBarVisible = this.isVisible(Parts.AUXILIARYBAR_PART); + if (auxiliaryBarVisible || (isNewWindow && activityBarNotDefault)) { const viewContainerToRestore = this.storageService.get(AuxiliaryBarPart.activePanelSettingsKey, StorageScope.WORKSPACE, this.viewDescriptorService.getDefaultViewContainer(ViewContainerLocation.AuxiliaryBar)?.id); if (viewContainerToRestore) { this.state.initialization.views.containerToRestore.auxiliaryBar = viewContainerToRestore; - } else { - this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN, true); + } + + if (auxiliaryBarVisible !== !!viewContainerToRestore) { + this.stateModel.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN, !auxiliaryBarVisible); } }