提交 cb5cfb8a 编写于 作者: B Benjamin Pasero

grid - adopt editor picker

上级 5e5e4e37
......@@ -29,10 +29,10 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import {
CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, JoinTwoGroupsAction, OpenToSideAction, RevertAndCloseEditorAction,
NavigateBetweenGroupsAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInGroupOneAction,
NavigateBetweenGroupsAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup,
toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, NavigateLastAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction,
OpenPreviousEditorFromHistoryAction, ShowAllEditorsAction, ClearEditorHistoryAction, ShowEditorsInGroupTwoAction, MoveEditorRightInGroupAction, OpenNextEditorInGroup, OpenPreviousEditorInGroup, OpenNextRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorAction,
ShowEditorsInGroupThreeAction, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorToFirstGroupAction, MoveEditorToSecondGroupAction, MoveEditorToThirdGroupAction, MoveEditorLeftInGroupAction, ClearRecentFilesAction, OpenLastEditorInGroup, SplitEditorGroupHorizontalAction, SplitEditorGroupVerticalAction, RemoveActiveEditorGroupAction
OpenPreviousEditorFromHistoryAction, ShowAllEditorsAction, ClearEditorHistoryAction, MoveEditorRightInGroupAction, OpenNextEditorInGroup, OpenPreviousEditorInGroup, OpenNextRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorAction,
FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorToFirstGroupAction, MoveEditorToSecondGroupAction, MoveEditorToThirdGroupAction, MoveEditorLeftInGroupAction, ClearRecentFilesAction, OpenLastEditorInGroup, SplitEditorGroupHorizontalAction, SplitEditorGroupVerticalAction, RemoveActiveEditorGroupAction, ShowEditorsInActiveGroupAction
} from 'vs/workbench/browser/parts/editor/editorActions';
import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
......@@ -40,7 +40,7 @@ import { getQuickNavigateHandler, inQuickOpenContext } from 'vs/workbench/browse
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh } from 'vs/base/common/platform';
import { GroupOnePicker, GroupTwoPicker, GroupThreePicker, AllEditorsPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
import { AllEditorsPicker, ActiveEditorGroupPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
import { Schemas } from 'vs/base/common/network';
import { GridOpenEditorsAction, ResetGridEditorAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
......@@ -265,50 +265,20 @@ const editorPickerContext = ContextKeyExpr.and(inQuickOpenContext, ContextKeyExp
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
GroupOnePicker,
GroupOnePicker.ID,
editorCommands.NAVIGATE_IN_GROUP_ONE_PREFIX,
ActiveEditorGroupPicker,
ActiveEditorGroupPicker.ID,
editorCommands.NAVIGATE_IN_ACTIVE_GROUP_PREFIX,
editorPickerContextKey,
[
{
prefix: editorCommands.NAVIGATE_IN_GROUP_ONE_PREFIX,
prefix: editorCommands.NAVIGATE_IN_ACTIVE_GROUP_PREFIX,
needsEditor: false,
description: nls.localize('groupOnePicker', "Show Editors in First Group")
},
{
prefix: editorCommands.NAVIGATE_IN_GROUP_TWO_PREFIX,
needsEditor: false,
description: nls.localize('groupTwoPicker', "Show Editors in Second Group")
},
{
prefix: editorCommands.NAVIGATE_IN_GROUP_THREE_PREFIX,
needsEditor: false,
description: nls.localize('groupThreePicker', "Show Editors in Third Group")
description: nls.localize('groupOnePicker', "Show Editors in Active Group")
}
]
)
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
GroupTwoPicker,
GroupTwoPicker.ID,
editorCommands.NAVIGATE_IN_GROUP_TWO_PREFIX,
editorPickerContextKey,
[]
)
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
GroupThreePicker,
GroupThreePicker.ID,
editorCommands.NAVIGATE_IN_GROUP_THREE_PREFIX,
editorPickerContextKey,
[]
)
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
AllEditorsPicker,
......@@ -333,9 +303,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenLastEditorInGroup,
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextRecentlyUsedEditorAction, OpenNextRecentlyUsedEditorAction.ID, OpenNextRecentlyUsedEditorAction.LABEL), 'View: Open Next Recently Used Editor', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorAction.ID, OpenPreviousRecentlyUsedEditorAction.LABEL), 'View: Open Previous Recently Used Editor', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAllEditorsAction, ShowAllEditorsAction.ID, ShowAllEditorsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_P), mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Tab } }), 'View: Show All Editors', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInGroupOneAction, ShowEditorsInGroupOneAction.ID, ShowEditorsInGroupOneAction.LABEL), 'View: Show Editors in First Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInGroupTwoAction, ShowEditorsInGroupTwoAction.ID, ShowEditorsInGroupTwoAction.LABEL), 'View: Show Editors in Second Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInGroupThreeAction, ShowEditorsInGroupThreeAction.ID, ShowEditorsInGroupThreeAction.LABEL), 'View: Show Editors in Third Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInActiveGroupAction, ShowEditorsInActiveGroupAction.ID, ShowEditorsInActiveGroupAction.LABEL), 'View: Show Editors in Active Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditor, OpenNextEditor.ID, OpenNextEditor.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.PageDown, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.RightArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET] } }), 'View: Open Next Editor', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditor, OpenPreviousEditor.ID, OpenPreviousEditor.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.PageUp, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.LeftArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET] } }), 'View: Open Previous Editor', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ReopenClosedEditorAction, ReopenClosedEditorAction.ID, ReopenClosedEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_T }), 'View: Reopen Closed Editor', category);
......
......@@ -22,7 +22,7 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_IN_GROUP_ONE_PREFIX, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, NAVIGATE_IN_GROUP_THREE_PREFIX, NAVIGATE_IN_GROUP_TWO_PREFIX, ActiveEditorMoveArguments, ActiveEditorMovePositioning, EditorCommands } from 'vs/workbench/browser/parts/editor/editorCommands';
import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ActiveEditorMoveArguments, ActiveEditorMovePositioning, EditorCommands, NAVIGATE_IN_ACTIVE_GROUP_PREFIX } from 'vs/workbench/browser/parts/editor/editorCommands';
import { INextEditorGroupsService, GroupDirection as SplitDirection, INextEditorGroup, GroupsArrangement } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
......@@ -1159,51 +1159,17 @@ export class ClearRecentFilesAction extends Action {
}
}
export class ShowEditorsInGroupOneAction extends QuickOpenAction {
export class ShowEditorsInActiveGroupAction extends QuickOpenAction {
public static readonly ID = 'workbench.action.showEditorsInFirstGroup';
public static readonly LABEL = nls.localize('showEditorsInFirstGroup', "Show Editors in First Group");
public static readonly ID = 'workbench.action.showEditorsInActiveGroup';
public static readonly LABEL = nls.localize('showEditorsInActiveGroup', "Show Editors in Active Group");
constructor(
actionId: string,
actionLabel: string,
@IQuickOpenService quickOpenService: IQuickOpenService
) {
super(actionId, actionLabel, NAVIGATE_IN_GROUP_ONE_PREFIX, quickOpenService);
this.class = 'show-group-editors-action';
}
}
export class ShowEditorsInGroupTwoAction extends QuickOpenAction {
public static readonly ID = 'workbench.action.showEditorsInSecondGroup';
public static readonly LABEL = nls.localize('showEditorsInSecondGroup', "Show Editors in Second Group");
constructor(
actionId: string,
actionLabel: string,
@IQuickOpenService quickOpenService: IQuickOpenService
) {
super(actionId, actionLabel, NAVIGATE_IN_GROUP_TWO_PREFIX, quickOpenService);
this.class = 'show-group-editors-action';
}
}
export class ShowEditorsInGroupThreeAction extends QuickOpenAction {
public static readonly ID = 'workbench.action.showEditorsInThirdGroup';
public static readonly LABEL = nls.localize('showEditorsInThirdGroup', "Show Editors in Third Group");
constructor(
actionId: string,
actionLabel: string,
@IQuickOpenService quickOpenService: IQuickOpenService
) {
super(actionId, actionLabel, NAVIGATE_IN_GROUP_THREE_PREFIX, quickOpenService);
this.class = 'show-group-editors-action';
super(actionId, actionLabel, NAVIGATE_IN_ACTIVE_GROUP_PREFIX, quickOpenService);
}
}
......@@ -1223,8 +1189,7 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
id: string,
label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IKeybindingService private keybindingService: IKeybindingService,
@IEditorGroupService private editorGroupService: IEditorGroupService
@IKeybindingService private keybindingService: IKeybindingService
) {
super(id, label);
}
......@@ -1232,19 +1197,9 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
public run(): TPromise<any> {
const keys = this.keybindingService.lookupKeybindings(this.id);
const stacks = this.editorGroupService.getStacksModel();
if (stacks.activeGroup) {
const activePosition = stacks.positionOfGroup(stacks.activeGroup);
let prefix = NAVIGATE_IN_GROUP_ONE_PREFIX;
if (activePosition === Position.TWO) {
prefix = NAVIGATE_IN_GROUP_TWO_PREFIX;
} else if (activePosition === Position.THREE) {
prefix = NAVIGATE_IN_GROUP_THREE_PREFIX;
}
this.quickOpenService.show(prefix, { quickNavigateConfiguration: { keybindings: keys } });
}
this.quickOpenService.show(NAVIGATE_IN_ACTIVE_GROUP_PREFIX, { quickNavigateConfiguration: { keybindings: keys } });
return TPromise.as(true);
}
......@@ -1259,10 +1214,9 @@ export class OpenPreviousRecentlyUsedEditorInGroupAction extends BaseQuickOpenEd
id: string,
label: string,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IKeybindingService keybindingService: IKeybindingService,
@IEditorGroupService editorGroupService: IEditorGroupService
@IKeybindingService keybindingService: IKeybindingService
) {
super(id, label, quickOpenService, keybindingService, editorGroupService);
super(id, label, quickOpenService, keybindingService);
}
}
......@@ -1275,10 +1229,9 @@ export class OpenNextRecentlyUsedEditorInGroupAction extends BaseQuickOpenEditor
id: string,
label: string,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IKeybindingService keybindingService: IKeybindingService,
@IEditorGroupService editorGroupService: IEditorGroupService
@IKeybindingService keybindingService: IKeybindingService
) {
super(id, label, quickOpenService, keybindingService, editorGroupService);
super(id, label, quickOpenService, keybindingService);
}
}
......
......@@ -58,10 +58,8 @@ export const KEEP_EDITOR_COMMAND_ID = 'workbench.action.keepEditor';
export const SHOW_EDITORS_IN_GROUP = 'workbench.action.showEditorsInGroup';
export const TOGGLE_DIFF_INLINE_MODE = 'toggle.diff.editorMode';
export const NAVIGATE_IN_GROUP_ONE_PREFIX = 'edt one ';
export const NAVIGATE_IN_GROUP_TWO_PREFIX = 'edt two ';
export const NAVIGATE_IN_GROUP_THREE_PREFIX = 'edt three ';
export const NAVIGATE_ALL_EDITORS_GROUP_PREFIX = 'edt ';
export const NAVIGATE_IN_ACTIVE_GROUP_PREFIX = 'edt active ';
export function setup(): void {
registerActiveEditorMoveCommand();
......@@ -427,37 +425,20 @@ function registerEditorCommands() {
handler: (accessor, resource: URI, context: IEditorCommandsContext) => {
const editorGroupService = accessor.get(INextEditorGroupsService);
const quickOpenService = accessor.get(IQuickOpenService);
const editorService = accessor.get(INextEditorService);
const groupCount = editorGroupService.groups.length;
if (groupCount <= 1) {
if (editorGroupService.count <= 1) {
return quickOpenService.show(NAVIGATE_ALL_EDITORS_GROUP_PREFIX);
}
const { group } = groupAndInput(editorGroupService, editorService, context);
console.log(group);
// TODO@grid should not be constrained to three positions
// switch (group) {
// case Position.TWO:
// return quickOpenService.show(NAVIGATE_IN_GROUP_TWO_PREFIX);
// case Position.THREE:
// return quickOpenService.show(NAVIGATE_IN_GROUP_THREE_PREFIX);
// }
if (context && typeof context.groupId === 'number') {
editorGroupService.activateGroup(editorGroupService.getGroup(context.groupId)); // we need the group to be active
}
return quickOpenService.show(NAVIGATE_IN_GROUP_ONE_PREFIX);
return quickOpenService.show(NAVIGATE_IN_ACTIVE_GROUP_PREFIX);
}
});
}
function groupAndInput(editorGroupService: INextEditorGroupsService, editorService: INextEditorService, context?: IEditorCommandsContext): { group: INextEditorGroup, input: IEditorInput } {
// Resolve from context
const group = context ? editorGroupService.getGroup(context.groupId) : editorGroupService.activeGroup;
const input = group && types.isNumber(context.editorIndex) ? group.getEditor(context.editorIndex) : editorService.activeEditor;
return { group, input };
}
function resolveCommandsContext(editorGroupService: INextEditorGroupsService, context?: IEditorCommandsContext): { group: INextEditorGroup, editor: IEditorInput, control: IEditor } {
// Resolve from context
......
......@@ -8,7 +8,6 @@ import 'vs/css!./media/editorpicker';
import { TPromise } from 'vs/base/common/winjs.base';
import * as nls from 'vs/nls';
import URI from 'vs/base/common/uri';
import * as errors from 'vs/base/common/errors';
import { IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
import { IAutoFocus, Mode, IEntryRunContext, IQuickNavigateConfiguration, IModel } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenModel, QuickOpenEntry, QuickOpenEntryGroup, QuickOpenItemAccessor } from 'vs/base/parts/quickopen/browser/quickOpenModel';
......@@ -16,33 +15,27 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { getIconClasses } from 'vs/workbench/browser/labels';
import { IModelService } from 'vs/editor/common/services/modelService';
import { QuickOpenHandler } from 'vs/workbench/browser/quickopen';
import { Position } from 'vs/platform/editor/common/editor';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService, INextEditorGroup, EditorsOrder, GroupsOrder } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { EditorInput, toResource, IEditorGroup, IEditorStacksModel } from 'vs/workbench/common/editor';
import { EditorInput, toResource } from 'vs/workbench/common/editor';
import { compareItemsByScore, scoreItem, ScorerCache, prepareQuery } from 'vs/base/parts/quickopen/common/quickOpenScorer';
export class EditorPickerEntry extends QuickOpenEntryGroup {
private stacks: IEditorStacksModel;
constructor(
private editor: EditorInput,
private _group: IEditorGroup,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
private _group: INextEditorGroup,
@IModeService private modeService: IModeService,
@IModelService private modelService: IModelService,
@IEditorGroupService editorGroupService: IEditorGroupService
@IModelService private modelService: IModelService
) {
super();
this.stacks = editorGroupService.getStacksModel();
}
public getLabelOptions(): IIconLabelValueOptions {
return {
extraClasses: getIconClasses(this.modelService, this.modeService, this.getResource()),
italic: this._group.isPreview(this.editor)
italic: !this._group.isPinned(this.editor)
};
}
......@@ -54,7 +47,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup {
return this.editor.isDirty() ? 'dirty' : '';
}
public get group(): IEditorGroup {
public get group(): INextEditorGroup {
return this._group;
}
......@@ -79,7 +72,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup {
}
private runOpen(context: IEntryRunContext): boolean {
this.editorService.openEditor(this.editor, null, this.stacks.positionOfGroup(this.group)).done(null, errors.onUnexpectedError);
this._group.openEditor(this.editor);
return true;
}
......@@ -90,8 +83,8 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
constructor(
@IInstantiationService protected instantiationService: IInstantiationService,
@IWorkbenchEditorService protected editorService: IWorkbenchEditorService,
@IEditorGroupService protected editorGroupService: IEditorGroupService
@INextEditorService protected editorService: INextEditorService,
@INextEditorGroupsService protected editorGroupService: INextEditorGroupsService
) {
super();
......@@ -123,11 +116,11 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
});
// Sorting
const stacks = this.editorGroupService.getStacksModel();
if (query.value) {
const groups = this.editorGroupService.getGroups(GroupsOrder.CREATION_TIME);
entries.sort((e1, e2) => {
if (e1.group !== e2.group) {
return stacks.positionOfGroup(e1.group) - stacks.positionOfGroup(e2.group);
return groups.indexOf(e1.group) - groups.indexOf(e2.group); // older groups first
}
return compareItemsByScore(e1, e2, query, true, QuickOpenItemAccessor, this.scorerCache);
......@@ -135,11 +128,11 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
}
// Grouping (for more than one group)
if (stacks.groups.length > 1) {
let lastGroup: IEditorGroup;
if (this.editorGroupService.count > 1) {
let lastGroup: INextEditorGroup;
entries.forEach(e => {
if (!lastGroup || lastGroup !== e.group) {
e.setGroupLabel(nls.localize('groupLabel', "Group: {0}", e.group.id));
e.setGroupLabel(e.group.label);
e.setShowBorder(!!lastGroup);
lastGroup = e.group;
}
......@@ -156,19 +149,17 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
protected abstract getEditorEntries(): EditorPickerEntry[];
}
export abstract class EditorGroupPicker extends BaseEditorPicker {
export class ActiveEditorGroupPicker extends BaseEditorPicker {
protected getEditorEntries(): EditorPickerEntry[] {
const stacks = this.editorGroupService.getStacksModel();
const group = stacks.groupAt(this.getPosition());
if (!group) {
return [];
}
public static readonly ID = 'workbench.picker.activeEditors';
return group.getEditors(true).map((editor, index) => this.instantiationService.createInstance(EditorPickerEntry, editor, group));
protected getEditorEntries(): EditorPickerEntry[] {
return this.group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).map((editor, index) => this.instantiationService.createInstance(EditorPickerEntry, editor, this.group));
}
protected abstract getPosition(): Position;
private get group(): INextEditorGroup {
return this.editorGroupService.activeGroup;
}
public getEmptyLabel(searchString: string): string {
if (searchString) {
......@@ -185,59 +176,29 @@ export abstract class EditorGroupPicker extends BaseEditorPicker {
};
}
const stacks = this.editorGroupService.getStacksModel();
const group = stacks.groupAt(this.getPosition());
if (!group) {
return super.getAutoFocus(searchValue, context);
}
const isShiftNavigate = (context.quickNavigateConfiguration && context.quickNavigateConfiguration.keybindings.some(k => {
const [firstPart, chordPart] = k.getParts();
if (chordPart) {
return false;
}
return firstPart.shiftKey;
}));
if (isShiftNavigate) {
return {
autoFocusLastEntry: true
};
}
const editors = this.group.count;
return {
autoFocusFirstEntry: group.count === 1,
autoFocusSecondEntry: group.count > 1
autoFocusFirstEntry: editors === 1,
autoFocusSecondEntry: editors > 1
};
}
}
export class GroupOnePicker extends EditorGroupPicker {
public static readonly ID = 'workbench.picker.editors.one';
protected getPosition(): Position {
return Position.ONE;
}
}
export class GroupTwoPicker extends EditorGroupPicker {
public static readonly ID = 'workbench.picker.editors.two';
protected getPosition(): Position {
return Position.TWO;
}
}
export class GroupThreePicker extends EditorGroupPicker {
public static readonly ID = 'workbench.picker.editors.three';
protected getPosition(): Position {
return Position.THREE;
}
}
export class AllEditorsPicker extends BaseEditorPicker {
public static readonly ID = 'workbench.picker.editors';
......@@ -245,9 +206,8 @@ export class AllEditorsPicker extends BaseEditorPicker {
protected getEditorEntries(): EditorPickerEntry[] {
const entries: EditorPickerEntry[] = [];
const stacks = this.editorGroupService.getStacksModel();
stacks.groups.forEach((group, position) => {
group.getEditors().forEach((editor, index) => {
this.editorGroupService.groups.forEach(group => {
group.editors.forEach(editor => {
entries.push(this.instantiationService.createInstance(EditorPickerEntry, editor, group));
});
});
......
......@@ -19,7 +19,7 @@ import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorBackground, contrastBorder, focusBorder } from 'vs/platform/theme/common/colorRegistry';
import { Themable, EDITOR_GROUP_HEADER_TABS_BORDER, EDITOR_GROUP_HEADER_TABS_BACKGROUND, EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND, EDITOR_GROUP_ACTIVE_EMPTY_BACKGROUND, EDITOR_GROUP_EMPTY_BACKGROUND } from 'vs/workbench/common/theme';
import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind, EditorsOrder } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { NextTabsTitleControl } from 'vs/workbench/browser/parts/editor2/nextTabsTitleControl';
import { NextEditorControl } from 'vs/workbench/browser/parts/editor2/nextEditorControl';
import { IProgressService } from 'vs/platform/progress/common/progress';
......@@ -578,6 +578,14 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
return this._group.isActive(editor);
}
getEditors(order?: EditorsOrder): EditorInput[] {
if (order === EditorsOrder.MOST_RECENTLY_ACTIVE) {
return this._group.getEditors(true);
}
return this.editors;
}
getEditor(index: number): EditorInput {
return this._group.getEditor(index);
}
......
......@@ -85,11 +85,24 @@ export enum GroupsOrder {
MOST_RECENTLY_ACTIVE,
/**
* Groups sorted by strict grid order
* Groups sorted by grid widget order
*/
GRID_APPEARANCE
}
export enum EditorsOrder {
/**
* Editors sorted by most recent activity (most recent active first)
*/
MOST_RECENTLY_ACTIVE,
/**
* Editors sorted by tabs order
*/
TAB_APPEARANCE
}
export interface INextEditorGroupsService {
_serviceBrand: ServiceIdentifier<any>;
......@@ -338,6 +351,13 @@ export interface INextEditorGroup {
*/
getEditor(index: number): IEditorInput;
/**
* Get all editors that are currently opened in the group optionally
* sorted by being most recent active. Will sort by sequential appearance
* by default (from left to right).
*/
getEditors(order?: EditorsOrder): ReadonlyArray<IEditorInput>;
/**
* Returns the index of the editor in the group or -1 if not opened.
*/
......
......@@ -8,7 +8,7 @@
import * as assert from 'assert';
import { NextEditorPart } from 'vs/workbench/browser/parts/editor2/nextEditorPart';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, EditorsOrder } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { Dimension } from 'vs/base/browser/dom';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INextEditorPartOptions } from 'vs/workbench/browser/parts/editor2/editor2';
......@@ -437,6 +437,10 @@ suite('Editor groups service (editor2)', () => {
assert.ok(group.activeControl instanceof TestEditorControl);
assert.equal(group.editors.length, 2);
const mru = group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE);
assert.equal(mru[0], input);
assert.equal(mru[1], inputInactive);
return group.openEditor(inputInactive).then(() => {
assert.equal(activeEditorChangeCounter, 2);
assert.equal(group.activeEditor, inputInactive);
......
......@@ -68,7 +68,7 @@ import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensi
import { IKeybindingService } from '../../platform/keybinding/common/keybinding';
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { INextEditorGroupsService, INextEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { INextEditorGroupsService, INextEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, EditorsOrder } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { INextEditorService, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/nextEditorService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
......@@ -796,6 +796,10 @@ export class TestNextEditorGroup implements INextEditorGroup {
onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
onDidOpenEditorFail: Event<IEditorInput> = Event.None;
getEditors(order?: EditorsOrder): ReadonlyArray<IEditorInput> {
return [];
}
getEditor(index: number): IEditorInput {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册