Skip to content

Commit

Permalink
fixes #141398
Browse files Browse the repository at this point in the history
  • Loading branch information
sbatten committed Jan 27, 2022
1 parent ddb419c commit 877c962
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/vs/workbench/browser/parts/panel/panelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -422,12 +422,38 @@ MenuRegistry.appendMenuItems([
}
]);

class MoveViewsBetweenPanelsAction extends Action2 {
constructor(private readonly source: ViewContainerLocation, private readonly destination: ViewContainerLocation, desc: Readonly<IAction2Options>) {
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"),
Expand All @@ -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"),
Expand All @@ -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);

0 comments on commit 877c962

Please sign in to comment.