From 877c9629b5f367264ad469908b3ba40ee673abc6 Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Wed, 26 Jan 2022 16:55:15 -0800 Subject: [PATCH] fixes #141398 --- .../browser/parts/panel/panelActions.ts | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/vs/workbench/browser/parts/panel/panelActions.ts b/src/vs/workbench/browser/parts/panel/panelActions.ts index e7711b150a819..9035c0b16b1c4 100644 --- a/src/vs/workbench/browser/parts/panel/panelActions.ts +++ b/src/vs/workbench/browser/parts/panel/panelActions.ts @@ -8,7 +8,7 @@ import { localize } from 'vs/nls'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { Action } from 'vs/base/common/actions'; import { Registry } from 'vs/platform/registry/common/platform'; -import { SyncActionDescriptor, MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; +import { SyncActionDescriptor, MenuId, MenuRegistry, registerAction2, Action2, IAction2Options } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions, CATEGORIES } from 'vs/workbench/common/actions'; import { IWorkbenchLayoutService, PanelAlignment, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService'; import { ActivityAction, ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositeBarActions'; @@ -18,7 +18,7 @@ import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/com import { Codicon } from 'vs/base/common/codicons'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; import { ServicesAccessor } from 'vs/editor/browser/editorExtensions'; -import { ViewContainerLocationToString, ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views'; +import { ViewContainerLocationToString, ViewContainerLocation, IViewDescriptorService, IViewsService } from 'vs/workbench/common/views'; import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -422,12 +422,38 @@ MenuRegistry.appendMenuItems([ } ]); +class MoveViewsBetweenPanelsAction extends Action2 { + constructor(private readonly source: ViewContainerLocation, private readonly destination: ViewContainerLocation, desc: Readonly) { + super(desc); + } + + run(accessor: ServicesAccessor, ...args: any[]): void { + const viewDescriptorService = accessor.get(IViewDescriptorService); + const layoutService = accessor.get(IWorkbenchLayoutService); + const viewsService = accessor.get(IViewsService); + + const srcContainers = viewDescriptorService.getViewContainersByLocation(this.source); + const destContainers = viewDescriptorService.getViewContainersByLocation(this.destination); + + if (srcContainers.length) { + const activeViewContainer = viewsService.getVisibleViewContainer(this.source); + + srcContainers.forEach(viewContainer => viewDescriptorService.moveViewContainerToLocation(viewContainer, this.destination)); + layoutService.setPartHidden(false, this.destination === ViewContainerLocation.Panel ? Parts.PANEL_PART : Parts.AUXILIARYBAR_PART); + + if (activeViewContainer && destContainers.length === 0) { + viewsService.openViewContainer(activeViewContainer.id, true); + } + } + } +} + // --- Move Panel Views To Side Panel -export class MovePanelToSidePanelAction extends Action2 { +export class MovePanelToSidePanelAction extends MoveViewsBetweenPanelsAction { static readonly ID = 'workbench.action.movePanelToSidePanel'; constructor() { - super({ + super(ViewContainerLocation.Panel, ViewContainerLocation.AuxiliaryBar, { id: MovePanelToSidePanelAction.ID, title: { value: localize('movePanelToSidePanel', "Move Views From Panel To Side Panel"), @@ -443,29 +469,17 @@ export class MovePanelToSidePanelAction extends Action2 { }] }); } - run(accessor: ServicesAccessor, ...args: any[]): void { - const viewDescriptorService = accessor.get(IViewDescriptorService); - const layoutService = accessor.get(IWorkbenchLayoutService); - - const panelContainers = viewDescriptorService.getViewContainersByLocation(ViewContainerLocation.Panel); - - if (panelContainers.length) { - panelContainers.forEach(viewContainer => viewDescriptorService.moveViewContainerToLocation(viewContainer, ViewContainerLocation.AuxiliaryBar)); - layoutService.setPartHidden(false, Parts.AUXILIARYBAR_PART); - } - } - } registerAction2(MovePanelToSidePanelAction); // --- Move Panel Views To Side Panel -export class MoveSidePanelToPanelAction extends Action2 { +export class MoveSidePanelToPanelAction extends MoveViewsBetweenPanelsAction { static readonly ID = 'workbench.action.moveSidePanelToPanel'; constructor() { - super({ + super(ViewContainerLocation.AuxiliaryBar, ViewContainerLocation.Panel, { id: MoveSidePanelToPanelAction.ID, title: { value: localize('moveSidePanelToPanel', "Move Views From Side Panel To Panel"), @@ -475,17 +489,5 @@ export class MoveSidePanelToPanelAction extends Action2 { f1: true }); } - run(accessor: ServicesAccessor, ...args: any[]): void { - const viewDescriptorService = accessor.get(IViewDescriptorService); - const layoutService = accessor.get(IWorkbenchLayoutService); - - const auxiliaryBarContainers = viewDescriptorService.getViewContainersByLocation(ViewContainerLocation.AuxiliaryBar); - - if (auxiliaryBarContainers.length) { - auxiliaryBarContainers.forEach(viewContainer => viewDescriptorService.moveViewContainerToLocation(viewContainer, ViewContainerLocation.Panel)); - layoutService.setPartHidden(false, Parts.PANEL_PART); - } - } - } registerAction2(MoveSidePanelToPanelAction);