diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 33eb7d50e792f..d199084e616ac 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -1087,7 +1087,6 @@ export class ToggleGroupSizesAction extends Action2 { } } - export class MaximizeGroupHideSidebarAction extends Action2 { constructor() { diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 630db73810a5c..7d25c62f7aa83 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -375,7 +375,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { this.gridWidget.resizeView(groupView, size); } - arrangeGroups(arrangement: GroupsArrangement, target = this.activeGroup): void { + arrangeGroups(arrangement: GroupsArrangement, target: IEditorGroupView | GroupIdentifier = this.activeGroup): void { if (this.count < 2) { return; // require at least 2 groups to show } @@ -384,6 +384,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { return; // we have not been created yet } + const groupView = this.assertGroupView(target); + switch (arrangement) { case GroupsArrangement.EVEN: this.gridWidget.distributeViewSizes(); @@ -392,16 +394,16 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { if (this.groups.length < 2) { return; // need at least 2 groups to be maximized } - this.gridWidget.maximizeView(target); - target.focus(); + this.gridWidget.maximizeView(groupView); + groupView.focus(); break; case GroupsArrangement.EXPAND: - this.gridWidget.expandView(target); + this.gridWidget.expandView(groupView); break; } } - toggleMaximizeGroup(target: IEditorGroupView = this.activeGroup): void { + toggleMaximizeGroup(target: IEditorGroupView | GroupIdentifier = this.activeGroup): void { if (this.hasMaximizedGroup()) { this.unmaximizeGroup(); } else { @@ -409,7 +411,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { } } - toggleExpandGroup(target: IEditorGroupView = this.activeGroup): void { + toggleExpandGroup(target: IEditorGroupView | GroupIdentifier = this.activeGroup): void { if (this.isGroupExpanded(this.activeGroup)) { this.arrangeGroups(GroupsArrangement.EVEN); } else { @@ -419,8 +421,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView { private unmaximizeGroup(): void { this.gridWidget.exitMaximizedView(); - // When making views visible the focus can be affected, so restore it - this._activeGroup.focus(); + this._activeGroup.focus(); // When making views visible the focus can be affected, so restore it } private hasMaximizedGroup(): boolean { diff --git a/src/vs/workbench/browser/parts/editor/editorParts.ts b/src/vs/workbench/browser/parts/editor/editorParts.ts index 0626bb73af6b9..06fd698bcd108 100644 --- a/src/vs/workbench/browser/parts/editor/editorParts.ts +++ b/src/vs/workbench/browser/parts/editor/editorParts.ts @@ -16,6 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { IAuxiliaryWindowOpenOptions, IAuxiliaryWindowService } from 'vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { WindowTitle } from 'vs/workbench/browser/parts/titlebar/windowTitle'; +import { distinct } from 'vs/base/common/arrays'; export class EditorParts extends Disposable implements IEditorGroupsService, IEditorPartsView { @@ -228,8 +229,14 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd getGroups(order = GroupsOrder.CREATION_TIME): IEditorGroupView[] { if (this._parts.size > 1) { - // TODO@bpasero support non-creation-time group orders across parts - return [...this._parts].map(part => part.getGroups(order)).flat(); + let parts: EditorPart[]; + if (order === GroupsOrder.MOST_RECENTLY_ACTIVE) { + parts = distinct([this.activePart, ...this._parts]); // put active part first in this order + } else { + parts = this.parts; + } + + return parts.map(part => part.getGroups(order)).flat(); } return this.mainPart.getGroups(order); @@ -260,15 +267,15 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd this.getPart(group).setSize(group, size); } - arrangeGroups(arrangement: GroupsArrangement, group?: IEditorGroupView): void { + arrangeGroups(arrangement: GroupsArrangement, group?: IEditorGroupView | GroupIdentifier): void { (group !== undefined ? this.getPart(group) : this.activePart).arrangeGroups(arrangement, group); } - toggleMaximizeGroup(group?: IEditorGroupView): void { + toggleMaximizeGroup(group?: IEditorGroupView | GroupIdentifier): void { (group !== undefined ? this.getPart(group) : this.activePart).toggleMaximizeGroup(group); } - toggleExpandGroup(group?: IEditorGroupView): void { + toggleExpandGroup(group?: IEditorGroupView | GroupIdentifier): void { (group !== undefined ? this.getPart(group) : this.activePart).toggleExpandGroup(group); }