diff --git a/src/vs/workbench/browser/parts/editor/editorPanes.ts b/src/vs/workbench/browser/parts/editor/editorPanes.ts index f57b9e54e1c..2f72fc9740e 100644 --- a/src/vs/workbench/browser/parts/editor/editorPanes.ts +++ b/src/vs/workbench/browser/parts/editor/editorPanes.ts @@ -132,7 +132,7 @@ export class EditorPanes extends Disposable { // Assert the `EditorInputCapabilities.AuxWindowUnsupported` condition if (getWindow(this.editorPanesParent) !== mainWindow && editor.hasCapability(EditorInputCapabilities.AuxWindowUnsupported)) { - return await this.doShowError(createEditorOpenError(localize('editorUnsupportedInAuxWindow', "This type of editor cannot be opened in floating windows yet."), [ + return await this.doShowError(createEditorOpenError(localize('editorUnsupportedInAuxWindow', "This type of editor cannot be opened in detached windows yet."), [ toAction({ id: 'workbench.editor.action.closeEditor', label: localize('openFolder', "Close Editor"), run: async () => { return this.groupView.closeEditor(editor); diff --git a/src/vs/workbench/browser/parts/editor/editorParts.ts b/src/vs/workbench/browser/parts/editor/editorParts.ts index e616262b6cd..2ce17e894ca 100644 --- a/src/vs/workbench/browser/parts/editor/editorParts.ts +++ b/src/vs/workbench/browser/parts/editor/editorParts.ts @@ -261,6 +261,21 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd return this.mainPart.getGroup(identifier); } + private assertGroupView(group: IEditorGroupView | GroupIdentifier): IEditorGroupView { + let groupView: IEditorGroupView | undefined; + if (typeof group === 'number') { + groupView = this.getGroup(group); + } else { + groupView = group; + } + + if (!groupView) { + throw new Error('Invalid editor group provided!'); + } + + return groupView; + } + activateGroup(group: IEditorGroupView | GroupIdentifier): IEditorGroupView { return this.getPart(group).activateGroup(group); } @@ -305,18 +320,46 @@ export class EditorParts extends Disposable implements IEditorGroupsService, IEd this.activePart.setGroupOrientation(orientation); } - findGroup(scope: IFindGroupScope, source?: IEditorGroupView | GroupIdentifier, wrap?: boolean): IEditorGroupView | undefined { - if (scope.location === GroupLocation.FIRST || scope.location === GroupLocation.LAST) { - // TODO implement support for all scopes with multiple editor parts - // https://github.com/microsoft/vscode/issues/198651 - return scope.location === GroupLocation.FIRST ? this.groups[0] : this.groups[this.groups.length - 1]; + findGroup(scope: IFindGroupScope, source: IEditorGroupView | GroupIdentifier = this.activeGroup, wrap?: boolean): IEditorGroupView | undefined { + const sourcePart = this.getPart(source); + if (this._parts.size > 1) { + const groups = this.getGroups(GroupsOrder.GRID_APPEARANCE); + + // Ensure that FIRST/LAST dispatches globally over all parts + if (scope.location === GroupLocation.FIRST || scope.location === GroupLocation.LAST) { + return scope.location === GroupLocation.FIRST ? groups[0] : groups[groups.length - 1]; + } + + // Try to find in target part first without wrapping + const group = sourcePart.findGroup(scope, source, false); + if (group) { + return group; + } + + // Ensure that NEXT/PREVIOUS dispatches globally over all parts + if (scope.location === GroupLocation.NEXT || scope.location === GroupLocation.PREVIOUS) { + const sourceGroup = this.assertGroupView(source); + const index = groups.indexOf(sourceGroup); + + if (scope.location === GroupLocation.NEXT) { + let nextGroup: IEditorGroupView | undefined = groups[index + 1]; + if (!nextGroup && wrap) { + nextGroup = groups[0]; + } + + return nextGroup; + } else { + let previousGroup: IEditorGroupView | undefined = groups[index - 1]; + if (!previousGroup && wrap) { + previousGroup = groups[groups.length - 1]; + } + + return previousGroup; + } + } } - if (source) { - return this.getPart(source).findGroup(scope, source, wrap); - } - - return this.activePart.findGroup(scope, source, wrap); + return sourcePart.findGroup(scope, source, wrap); } addGroup(location: IEditorGroupView | GroupIdentifier, direction: GroupDirection): IEditorGroupView { diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index a0c22da313c..a435aa0ccdf 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -247,7 +247,7 @@ const registry = Registry.as(ConfigurationExtensions.Con 'workbench.editor.dragToOpenWindow': { 'type': 'boolean', 'default': product.quality !== 'stable', - 'markdownDescription': localize('dragToOpenWindow', "Controls if editors can be dragged out of the window to open them in a new floating window. Press and hold `Alt`-key while dragging to toggle this dynamically.") + 'markdownDescription': localize('dragToOpenWindow', "Controls if editors can be dragged out of the window to open them in a new detached window. Press and hold `Alt`-key while dragging to toggle this dynamically.") }, 'workbench.editor.focusRecentEditorAfterClose': { 'type': 'boolean',