Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ben/slim-capybara #199638

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 35 additions & 21 deletions src/vs/workbench/browser/actions/navigationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
import { ViewContainerLocation } from 'vs/workbench/common/views';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { mainWindow } from 'vs/base/browser/window';
import { getActiveWindow } from 'vs/base/browser/dom';
import { isAuxiliaryWindow } from 'vs/base/browser/window';

abstract class BaseNavigationAction extends Action2 {

Expand Down Expand Up @@ -254,28 +255,41 @@ abstract class BaseFocusAction extends Action2 {
}

private findVisibleNeighbour(layoutService: IWorkbenchLayoutService, part: Parts, next: boolean): Parts {
const activeWindow = getActiveWindow();
const windowIsAuxiliary = isAuxiliaryWindow(activeWindow);

let neighbour: Parts;
switch (part) {
case Parts.EDITOR_PART:
neighbour = next ? Parts.PANEL_PART : Parts.SIDEBAR_PART;
break;
case Parts.PANEL_PART:
neighbour = next ? Parts.STATUSBAR_PART : Parts.EDITOR_PART;
break;
case Parts.STATUSBAR_PART:
neighbour = next ? Parts.ACTIVITYBAR_PART : Parts.PANEL_PART;
break;
case Parts.ACTIVITYBAR_PART:
neighbour = next ? Parts.SIDEBAR_PART : Parts.STATUSBAR_PART;
break;
case Parts.SIDEBAR_PART:
neighbour = next ? Parts.EDITOR_PART : Parts.ACTIVITYBAR_PART;
break;
default:
neighbour = Parts.EDITOR_PART;
if (windowIsAuxiliary) {
switch (part) {
case Parts.EDITOR_PART:
neighbour = Parts.STATUSBAR_PART;
break;
default:
neighbour = Parts.EDITOR_PART;
}
} else {
switch (part) {
case Parts.EDITOR_PART:
neighbour = next ? Parts.PANEL_PART : Parts.SIDEBAR_PART;
break;
case Parts.PANEL_PART:
neighbour = next ? Parts.STATUSBAR_PART : Parts.EDITOR_PART;
break;
case Parts.STATUSBAR_PART:
neighbour = next ? Parts.ACTIVITYBAR_PART : Parts.PANEL_PART;
break;
case Parts.ACTIVITYBAR_PART:
neighbour = next ? Parts.SIDEBAR_PART : Parts.STATUSBAR_PART;
break;
case Parts.SIDEBAR_PART:
neighbour = next ? Parts.EDITOR_PART : Parts.ACTIVITYBAR_PART;
break;
default:
neighbour = Parts.EDITOR_PART;
}
}

if (layoutService.isVisible(neighbour, mainWindow) || neighbour === Parts.EDITOR_PART) {
if (layoutService.isVisible(neighbour, activeWindow) || neighbour === Parts.EDITOR_PART) {
return neighbour;
}

Expand All @@ -296,7 +310,7 @@ abstract class BaseFocusAction extends Action2 {
currentlyFocusedPart = Parts.PANEL_PART;
}

layoutService.focusPart(currentlyFocusedPart ? this.findVisibleNeighbour(layoutService, currentlyFocusedPart, next) : Parts.EDITOR_PART, mainWindow);
layoutService.focusPart(currentlyFocusedPart ? this.findVisibleNeighbour(layoutService, currentlyFocusedPart, next) : Parts.EDITOR_PART, getActiveWindow());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class AuxiliaryEditorPartImpl extends EditorPart implements IAuxiliaryEditorPart
}

private doClose(mergeGroupsToMainPart: boolean): void {
if (mergeGroupsToMainPart) {
if (mergeGroupsToMainPart && this.groups.some(group => group.count > 0)) {
this.mergeAllGroups(this.editorPartsView.mainPart.activeGroup);
}

Expand Down
33 changes: 28 additions & 5 deletions src/vs/workbench/browser/parts/editor/editorParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { localize } from 'vs/nls';
import { EditorGroupLayout, GroupDirection, GroupLocation, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, IAuxiliaryEditorPartCreateEvent, IEditorDropTargetDelegate, IEditorGroupsService, IEditorSideGroup, IFindGroupScope, IMergeGroupOptions } from 'vs/workbench/services/editor/common/editorGroupsService';
import { Emitter } from 'vs/base/common/event';
import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { GroupIdentifier } from 'vs/workbench/common/editor';
import { EditorPart, MainEditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { IEditorGroupView, IEditorPartsView } from 'vs/workbench/browser/parts/editor/editor';
Expand All @@ -23,6 +23,8 @@ export class EditorParts extends MultiWindowParts<EditorPart> implements IEditor

readonly mainPart = this._register(this.createMainEditorPart());

private readonly mostRecentActiveParts = [this.mainPart];

constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
Expand Down Expand Up @@ -82,10 +84,13 @@ export class EditorParts extends MultiWindowParts<EditorPart> implements IEditor

private registerEditorPartListeners(part: EditorPart, disposables: DisposableStore): void {
disposables.add(part.onDidFocus(() => {
this.doUpdateMostRecentActive(part, true);

if (this._parts.size > 1) {
this._onDidActiveGroupChange.fire(this.activeGroup); // this can only happen when we have more than 1 editor part
}
}));
disposables.add(toDisposable(() => this.doUpdateMostRecentActive(part)));

disposables.add(part.onDidChangeActiveGroup(group => this._onDidActiveGroupChange.fire(group)));
disposables.add(part.onDidAddGroup(group => this._onDidAddGroup.fire(group)));
Expand All @@ -98,6 +103,20 @@ export class EditorParts extends MultiWindowParts<EditorPart> implements IEditor
disposables.add(part.onDidChangeGroupLocked(group => this._onDidChangeGroupLocked.fire(group)));
}

private doUpdateMostRecentActive(part: EditorPart, makeMostRecentlyActive?: boolean): void {
const index = this.mostRecentActiveParts.indexOf(part);

// Remove from MRU list
if (index !== -1) {
this.mostRecentActiveParts.splice(index, 1);
}

// Add to front as needed
if (makeMostRecentlyActive) {
this.mostRecentActiveParts.unshift(part);
}
}

private getGroupsLabel(index: number): string {
return localize('groupLabel', "Window {0}", index + 1);
}
Expand Down Expand Up @@ -186,10 +205,14 @@ export class EditorParts extends MultiWindowParts<EditorPart> implements IEditor
getGroups(order = GroupsOrder.CREATION_TIME): IEditorGroupView[] {
if (this._parts.size > 1) {
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;
switch (order) {
case GroupsOrder.GRID_APPEARANCE: // we currently do not have a way to compute by appearance over multiple windows
case GroupsOrder.CREATION_TIME:
parts = this.parts;
break;
case GroupsOrder.MOST_RECENTLY_ACTIVE:
parts = distinct([...this.mostRecentActiveParts, ...this.parts]); // always ensure all parts are included
break;
}

return parts.map(part => part.getGroups(order)).flat();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
}));

if (isMacintosh) {
this._register(addDisposableListener(this.title, EventType.CLICK, e => {
this._register(addDisposableListener(this.title, EventType.MOUSE_DOWN, e => {
if (e.metaKey) {
EventHelper.stop(e, true /* stop bubbling to prevent command center from opening */);

Expand Down