Skip to content

Commit 54d31be

Browse files
benibenjbpasero
andauthored
Tabs Multi Select Polish (microsoft#212930)
* Tabs Multi Select Polish * 💄 * add todo * add todo * update * 💄 * 💄 * 💄 * more review * 💄 * 💄 * fix bad function call * remove todo * jsdoc * 💄 * fix typo * 💄 * 💄 * 💄 multiEditorTabs * model accepts multiple editors * Use setSelection() * fix tests * 💄 * 💄 * discussion * discussion * fix selection * typo --------- Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
1 parent b903ddb commit 54d31be

21 files changed

+271
-356
lines changed

src/vs/workbench/browser/parts/editor/editor.contribution.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
TextCompareEditorActiveContext, ActiveEditorPinnedContext, EditorGroupEditorsCountContext, ActiveEditorStickyContext, ActiveEditorAvailableEditorIdsContext,
1212
EditorPartMultipleEditorGroupsContext, ActiveEditorDirtyContext, ActiveEditorGroupLockedContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext,
1313
EditorTabsVisibleContext, ActiveEditorLastInGroupContext, EditorPartMaximizedEditorGroupContext, MultipleEditorGroupsContext, InEditorZenModeContext,
14-
IsAuxiliaryEditorPartContext, ActiveCompareEditorCanSwapContext, MultipleEditorsSelectedContext
14+
IsAuxiliaryEditorPartContext, ActiveCompareEditorCanSwapContext, MultipleEditorsSelectedInGroupContext
1515
} from 'vs/workbench/common/contextkeys';
1616
import { SideBySideEditorInput, SideBySideEditorInputSerializer } from 'vs/workbench/common/editor/sideBySideEditorInput';
1717
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
@@ -388,7 +388,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorActionsPositionSubmenu, { command: { id
388388
// Editor Title Context Menu
389389
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_EDITOR_COMMAND_ID, title: localize('close', "Close") }, group: '1_close', order: 10 });
390390
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, title: localize('closeOthers', "Close Others"), precondition: EditorGroupEditorsCountContext.notEqualsTo('1') }, group: '1_close', order: 20 });
391-
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID, title: localize('closeRight', "Close to the Right"), precondition: ContextKeyExpr.and(ActiveEditorLastInGroupContext.toNegated(), MultipleEditorsSelectedContext.negate()) }, group: '1_close', order: 30, when: EditorTabsVisibleContext });
391+
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID, title: localize('closeRight', "Close to the Right"), precondition: ContextKeyExpr.and(ActiveEditorLastInGroupContext.toNegated(), MultipleEditorsSelectedInGroupContext.negate()) }, group: '1_close', order: 30, when: EditorTabsVisibleContext });
392392
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_SAVED_EDITORS_COMMAND_ID, title: localize('closeAllSaved', "Close Saved") }, group: '1_close', order: 40 });
393393
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_EDITORS_IN_GROUP_COMMAND_ID, title: localize('closeAll', "Close All") }, group: '1_close', order: 50 });
394394
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: REOPEN_WITH_COMMAND_ID, title: localize('reopenWith', "Reopen Editor With...") }, group: '1_open', order: 10, when: ActiveEditorAvailableEditorIdsContext });
@@ -399,11 +399,11 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_ED
399399
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_DOWN, title: localize('splitDown', "Split Down") }, group: '5_split', order: 20 });
400400
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_LEFT, title: localize('splitLeft', "Split Left") }, group: '5_split', order: 30 });
401401
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_RIGHT, title: localize('splitRight', "Split Right") }, group: '5_split', order: 40 });
402-
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_IN_GROUP, title: localize('splitInGroup', "Split in Group"), precondition: MultipleEditorsSelectedContext.negate() }, group: '6_split_in_group', order: 10, when: ActiveEditorCanSplitInGroupContext });
403-
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: JOIN_EDITOR_IN_GROUP, title: localize('joinInGroup', "Join in Group"), precondition: MultipleEditorsSelectedContext.negate() }, group: '6_split_in_group', order: 10, when: SideBySideEditorActiveContext });
402+
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: SPLIT_EDITOR_IN_GROUP, title: localize('splitInGroup', "Split in Group"), precondition: MultipleEditorsSelectedInGroupContext.negate() }, group: '6_split_in_group', order: 10, when: ActiveEditorCanSplitInGroupContext });
403+
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: JOIN_EDITOR_IN_GROUP, title: localize('joinInGroup', "Join in Group"), precondition: MultipleEditorsSelectedInGroupContext.negate() }, group: '6_split_in_group', order: 10, when: SideBySideEditorActiveContext });
404404
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: MOVE_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, title: localize('moveToNewWindow', "Move into New Window") }, group: '7_new_window', order: 10 });
405405
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: COPY_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, title: localize('copyToNewWindow', "Copy into New Window") }, group: '7_new_window', order: 20 });
406-
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { submenu: MenuId.EditorTitleContextShare, title: localize('share', "Share"), group: '11_share', order: -1, when: MultipleEditorsSelectedContext.negate() });
406+
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { submenu: MenuId.EditorTitleContextShare, title: localize('share', "Share"), group: '11_share', order: -1, when: MultipleEditorsSelectedInGroupContext.negate() });
407407

408408
// Editor Title Menu
409409
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: TOGGLE_DIFF_SIDE_BY_SIDE, title: localize('inlineView', "Inline View"), toggled: ContextKeyExpr.equals('config.diffEditor.renderSideBySide', false) }, group: '1_diff', order: 10, when: ContextKeyExpr.has('isInDiffEditor') });

src/vs/workbench/browser/parts/editor/editor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ export interface IInternalEditorOpenOptions extends IInternalEditorTitleControlO
340340
readonly preserveWindowOrder?: boolean;
341341

342342
/**
343-
* Whether to add the editor to the selection or not.
343+
* Inactive editors to select after opening the active selected editor.
344344
*/
345-
readonly selected?: boolean;
345+
readonly inactiveSelection?: EditorInput[];
346346
}
347347

348348
export interface IInternalEditorCloseOptions extends IInternalEditorTitleControlOptions {

src/vs/workbench/browser/parts/editor/editorActions.ts

+11-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/bro
1313
import { GoFilter, IHistoryService } from 'vs/workbench/services/history/common/history';
1414
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1515
import { ICommandService } from 'vs/platform/commands/common/commands';
16-
import { CLOSE_EDITOR_COMMAND_ID, MOVE_ACTIVE_EDITOR_COMMAND_ID, ActiveEditorMoveCopyArguments, SPLIT_EDITOR_LEFT, SPLIT_EDITOR_RIGHT, SPLIT_EDITOR_UP, SPLIT_EDITOR_DOWN, splitEditor, LAYOUT_EDITOR_GROUPS_COMMAND_ID, UNPIN_EDITOR_COMMAND_ID, COPY_ACTIVE_EDITOR_COMMAND_ID, SPLIT_EDITOR, resolveCommandsContext, getCommandsContext, TOGGLE_MAXIMIZE_EDITOR_GROUP, MOVE_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, COPY_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, MOVE_EDITOR_GROUP_INTO_NEW_WINDOW_COMMAND_ID, COPY_EDITOR_GROUP_INTO_NEW_WINDOW_COMMAND_ID, NEW_EMPTY_EDITOR_WINDOW_COMMAND_ID as NEW_EMPTY_EDITOR_WINDOW_COMMAND_ID, getEditorsFromContext } from 'vs/workbench/browser/parts/editor/editorCommands';
16+
import { CLOSE_EDITOR_COMMAND_ID, MOVE_ACTIVE_EDITOR_COMMAND_ID, ActiveEditorMoveCopyArguments, SPLIT_EDITOR_LEFT, SPLIT_EDITOR_RIGHT, SPLIT_EDITOR_UP, SPLIT_EDITOR_DOWN, splitEditor, LAYOUT_EDITOR_GROUPS_COMMAND_ID, UNPIN_EDITOR_COMMAND_ID, COPY_ACTIVE_EDITOR_COMMAND_ID, SPLIT_EDITOR, resolveCommandsContext, getCommandsContext, TOGGLE_MAXIMIZE_EDITOR_GROUP, MOVE_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, COPY_EDITOR_INTO_NEW_WINDOW_COMMAND_ID, MOVE_EDITOR_GROUP_INTO_NEW_WINDOW_COMMAND_ID, COPY_EDITOR_GROUP_INTO_NEW_WINDOW_COMMAND_ID, NEW_EMPTY_EDITOR_WINDOW_COMMAND_ID as NEW_EMPTY_EDITOR_WINDOW_COMMAND_ID, resolveEditorsContext, getEditorsContext } from 'vs/workbench/browser/parts/editor/editorCommands';
1717
import { IEditorGroupsService, IEditorGroup, GroupsArrangement, GroupLocation, GroupDirection, preferredSideBySideGroupDirection, IFindGroupScope, GroupOrientation, EditorGroupLayout, GroupsOrder, MergeGroupMode } from 'vs/workbench/services/editor/common/editorGroupsService';
1818
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1919
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -65,7 +65,8 @@ abstract class AbstractSplitEditorAction extends Action2 {
6565
const editorGroupService = accessor.get(IEditorGroupsService);
6666
const configurationService = accessor.get(IConfigurationService);
6767

68-
splitEditor(editorGroupService, this.getDirection(configurationService), [getCommandsContext(accessor, resourceOrContext, context)]);
68+
const commandContext = getCommandsContext(accessor, resourceOrContext, context);
69+
splitEditor(editorGroupService, this.getDirection(configurationService), commandContext ? [commandContext] : undefined);
6970
}
7071
}
7172

@@ -2514,23 +2515,19 @@ abstract class BaseMoveCopyEditorToNewWindowAction extends Action2 {
25142515

25152516
override async run(accessor: ServicesAccessor, resourceOrContext?: URI | IEditorCommandsContext, context?: IEditorCommandsContext) {
25162517
const editorGroupService = accessor.get(IEditorGroupsService);
2517-
const editors = getEditorsFromContext(accessor, resourceOrContext, context);
2518-
2519-
// If there is no editor, do not create a new window
2520-
if (editors.length === 0) {
2518+
const editorsContext = resolveEditorsContext(getEditorsContext(accessor, resourceOrContext, context));
2519+
if (editorsContext.length === 0) {
25212520
return;
25222521
}
25232522

25242523
const auxiliaryEditorPart = await editorGroupService.createAuxiliaryEditorPart();
25252524

2526-
for (const { editor, group } of editors) {
2527-
if (group && editor) {
2528-
if (this.move) {
2529-
group.moveEditor(editor, auxiliaryEditorPart.activeGroup);
2530-
} else {
2531-
group.copyEditor(editor, auxiliaryEditorPart.activeGroup);
2532-
}
2533-
}
2525+
const sourceGroup = editorsContext[0].group; // only single group supported for move/copy for now
2526+
const sourceEditors = editorsContext.filter(({ group }) => group === sourceGroup);
2527+
if (this.move) {
2528+
sourceGroup.moveEditors(sourceEditors, auxiliaryEditorPart.activeGroup);
2529+
} else {
2530+
sourceGroup.copyEditors(sourceEditors, auxiliaryEditorPart.activeGroup);
25342531
}
25352532

25362533
auxiliaryEditorPart.activeGroup.focus();

0 commit comments

Comments
 (0)