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

Align Open Editor and double arrow down (fixes #6764)

上级 5684c025
......@@ -33,9 +33,10 @@ import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
import {EditorStacksModel} from 'vs/workbench/common/editor/editorStacksModel';
import {CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, PinEditorAction, UnpinEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction,
NavigateBetweenGroupsAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInGroupAction,
toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousEditorInGroupAction, NAVIGATE_IN_GROUP_PREFIX,
GlobalQuickOpenAction, OpenPreviousEditorFromHistoryAction, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction
NavigateBetweenGroupsAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInLeftGroupAction,
toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousEditorInGroupAction, NAVIGATE_IN_LEFT_GROUP_PREFIX,
GlobalQuickOpenAction, OpenPreviousEditorFromHistoryAction, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInCenterGroupAction,
NAVIGATE_IN_CENTER_GROUP_PREFIX, ShowEditorsInRightGroupAction, NAVIGATE_IN_RIGHT_GROUP_PREFIX
} from 'vs/workbench/browser/parts/editor/editorActions';
// Register String Editor
......@@ -248,13 +249,43 @@ actionBarRegistry.registerActionBarContributor(Scope.VIEWER, QuickOpenActionCont
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/browser/parts/editor/editorPicker',
'EditorGroupPicker',
NAVIGATE_IN_GROUP_PREFIX,
'LeftEditorGroupPicker',
NAVIGATE_IN_LEFT_GROUP_PREFIX,
[
{
prefix: NAVIGATE_IN_GROUP_PREFIX,
prefix: NAVIGATE_IN_LEFT_GROUP_PREFIX,
needsEditor: false,
description: nls.localize('editorGroupPicker', "Show Editors in Active Group")
description: nls.localize('leftEditorGroupPicker', "Show Editors in Left Group")
}
]
)
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/browser/parts/editor/editorPicker',
'CenterEditorGroupPicker',
NAVIGATE_IN_CENTER_GROUP_PREFIX,
[
{
prefix: NAVIGATE_IN_CENTER_GROUP_PREFIX,
needsEditor: false,
description: nls.localize('centerEditorGroupPicker', "Show Editors in Center Group")
}
]
)
);
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/browser/parts/editor/editorPicker',
'RightEditorGroupPicker',
NAVIGATE_IN_RIGHT_GROUP_PREFIX,
[
{
prefix: NAVIGATE_IN_RIGHT_GROUP_PREFIX,
needsEditor: false,
description: nls.localize('rightEditorGroupPicker', "Show Editors in Right Group")
}
]
)
......@@ -311,7 +342,9 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditorInGr
}
}), 'Open Previous in Editor Group');
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAllEditorsAction, ShowAllEditorsAction.ID, ShowAllEditorsAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Alt |  KeyCode.Tab }), 'View: Show All Editors', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInGroupAction, ShowEditorsInGroupAction.ID, ShowEditorsInGroupAction.LABEL), 'View: Show Editors in Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInLeftGroupAction, ShowEditorsInLeftGroupAction.ID, ShowEditorsInLeftGroupAction.LABEL), 'View: Show Editors in Left Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInCenterGroupAction, ShowEditorsInCenterGroupAction.ID, ShowEditorsInCenterGroupAction.LABEL), 'View: Show Editors in Center Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInRightGroupAction, ShowEditorsInRightGroupAction.ID, ShowEditorsInRightGroupAction.LABEL), 'View: Show Editors in Left Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditor, OpenNextEditor.ID, OpenNextEditor.LABEL, {
primary: KeyMod.CtrlCmd | KeyCode.PageDown,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.RightArrow }
......
......@@ -861,12 +861,12 @@ export class ReopenClosedEditorAction extends Action {
}
}
export const NAVIGATE_IN_GROUP_PREFIX = '~>';
export const NAVIGATE_IN_LEFT_GROUP_PREFIX = 'edt left ';
export class ShowEditorsInGroupAction extends QuickOpenAction {
export class ShowEditorsInLeftGroupAction extends QuickOpenAction {
public static ID = 'workbench.action.showEditorsInGroup';
public static LABEL = nls.localize('showEditorsInGroup', "Show Editors in Group");
public static ID = 'workbench.action.showEditorsInLeftGroup';
public static LABEL = nls.localize('showEditorsInLeftGroup', "Show Editors in Left Group");
constructor(
actionId: string,
......@@ -874,19 +874,45 @@ export class ShowEditorsInGroupAction extends QuickOpenAction {
@IQuickOpenService quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(actionId, actionLabel, NAVIGATE_IN_GROUP_PREFIX, quickOpenService);
super(actionId, actionLabel, NAVIGATE_IN_LEFT_GROUP_PREFIX, quickOpenService);
}
}
public run(editorIdentifier: IEditorIdentifier): TPromise<any> {
if (editorIdentifier) {
this.editorService.activateGroup(this.editorService.getStacksModel().positionOfGroup(editorIdentifier.group)); // workaround for not having a group specific quick open for opened editors
}
export const NAVIGATE_IN_CENTER_GROUP_PREFIX = 'edt center ';
export class ShowEditorsInCenterGroupAction extends QuickOpenAction {
return super.run(editorIdentifier);
public static ID = 'workbench.action.showEditorsInCenterGroup';
public static LABEL = nls.localize('showEditorsInCenterGroup', "Show Editors in Center Group");
constructor(
actionId: string,
actionLabel: string,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(actionId, actionLabel, NAVIGATE_IN_CENTER_GROUP_PREFIX, quickOpenService);
}
}
export const NAVIGATE_ALL_EDITORS_GROUP_PREFIX = '~';
export const NAVIGATE_IN_RIGHT_GROUP_PREFIX = 'edt right ';
export class ShowEditorsInRightGroupAction extends QuickOpenAction {
public static ID = 'workbench.action.showEditorsInRightGroup';
public static LABEL = nls.localize('showEditorsInRightGroup', "Show Editors in Right Group");
constructor(
actionId: string,
actionLabel: string,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(actionId, actionLabel, NAVIGATE_IN_RIGHT_GROUP_PREFIX, quickOpenService);
}
}
export const NAVIGATE_ALL_EDITORS_GROUP_PREFIX = 'edt ';
export class ShowAllEditorsAction extends QuickOpenAction {
......@@ -907,7 +933,8 @@ export class OpenPreviousEditorInGroupAction extends Action {
id: string,
label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IKeybindingService private keybindingService: IKeybindingService
@IKeybindingService private keybindingService: IKeybindingService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(id, label);
}
......@@ -915,9 +942,22 @@ export class OpenPreviousEditorInGroupAction extends Action {
public run(): TPromise<any> {
let keys = this.keybindingService.lookupKeybindings(this.id);
this.quickOpenService.show(NAVIGATE_IN_GROUP_PREFIX, {
keybindings: keys
});
const stacks = this.editorService.getStacksModel();
if (stacks.activeGroup) {
const activePosition = stacks.positionOfGroup(stacks.activeGroup);
const count = stacks.groups.length;
let prefix = NAVIGATE_IN_LEFT_GROUP_PREFIX;
if (activePosition === Position.CENTER && count === 3) {
prefix = NAVIGATE_IN_CENTER_GROUP_PREFIX;
} else if (activePosition === Position.RIGHT || (activePosition === Position.CENTER && count === 2)) {
prefix = NAVIGATE_IN_RIGHT_GROUP_PREFIX;
}
this.quickOpenService.show(prefix, {
keybindings: keys
});
}
return TPromise.as(true);
}
......
......@@ -15,6 +15,7 @@ import {IAutoFocus, Mode, IContext} from 'vs/base/parts/quickopen/common/quickOp
import {QuickOpenModel, QuickOpenEntry, QuickOpenEntryGroup} from 'vs/base/parts/quickopen/browser/quickOpenModel';
import scorer = require('vs/base/common/scorer');
import {QuickOpenHandler} from 'vs/workbench/browser/quickopen';
import {Position} from 'vs/platform/editor/common/editor';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
......@@ -93,15 +94,17 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
}
public getResults(searchValue: string): TPromise<QuickOpenModel> {
const stacks = this.editorService.getStacksModel();
if (!stacks.activeGroup) {
searchValue = searchValue.trim();
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
const editorEntries = this.getEditorEntries();
if (!editorEntries.length) {
return TPromise.as(null);
}
searchValue = searchValue.trim();
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
const stacks = this.editorService.getStacksModel();
const entries = this.getEditorEntries().filter(e => {
const entries = editorEntries.filter(e => {
if (!searchValue) {
return true;
}
......@@ -149,14 +152,20 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
protected abstract getEditorEntries(): EditorPickerEntry[];
}
export class EditorGroupPicker extends BaseEditorPicker {
export abstract class EditorGroupPicker extends BaseEditorPicker {
protected getEditorEntries(): EditorPickerEntry[] {
const stacks = this.editorService.getStacksModel();
const group = stacks.groupAt(this.getPosition());
if (!group) {
return [];
}
return stacks.activeGroup.getEditors(true).map((editor, index) => this.instantiationService.createInstance(EditorPickerEntry, editor, stacks.activeGroup));
return group.getEditors(true).map((editor, index) => this.instantiationService.createInstance(EditorPickerEntry, editor, group));
}
protected abstract getPosition(): Position;
public getEmptyLabel(searchString: string): string {
if (searchString) {
return nls.localize('noResultsFoundInGroup', "No matching opened editor found in group");
......@@ -173,17 +182,43 @@ export class EditorGroupPicker extends BaseEditorPicker {
}
const stacks = this.editorService.getStacksModel();
if (!stacks.activeGroup) {
const group = stacks.groupAt(this.getPosition());
if (!group) {
return super.getAutoFocus(searchValue);
}
return {
autoFocusFirstEntry: stacks.activeGroup.count === 1,
autoFocusSecondEntry: stacks.activeGroup.count > 1
autoFocusFirstEntry: group.count === 1,
autoFocusSecondEntry: group.count > 1
};
}
}
export class LeftEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
return Position.LEFT;
}
}
export class CenterEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
const stacks = this.editorService.getStacksModel();
return stacks.groups.length > 2 ? Position.CENTER : -1; // with 2 groups open, the center one is not available
}
}
export class RightEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
const stacks = this.editorService.getStacksModel();
return stacks.groups.length > 2 ? Position.RIGHT : Position.CENTER;
}
}
export class AllEditorsPicker extends BaseEditorPicker {
protected getEditorEntries(): EditorPickerEntry[] {
......
......@@ -30,10 +30,11 @@ import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
import {Position, POSITIONS} from 'vs/platform/editor/common/editor';
import {IEventService} from 'vs/platform/event/common/event';
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {QuickOpenAction} from 'vs/workbench/browser/quickopen';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {ShowEditorsInGroupAction, CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, CloseEditorAction} from 'vs/workbench/browser/parts/editor/editorActions';
import {ShowEditorsInLeftGroupAction, ShowEditorsInCenterGroupAction, ShowEditorsInRightGroupAction, CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, CloseEditorAction} from 'vs/workbench/browser/parts/editor/editorActions';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
export enum Rochade {
......@@ -123,7 +124,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
private mapActionsToEditors: { [editorId: string]: IEditorActions; }[];
private closeEditorActions: CloseEditorAction[];
private showEditorsOfGroup: ShowEditorsInGroupAction[];
private showEditorsOfGroup: QuickOpenAction[];
private moveGroupLeftActions: MoveGroupLeftAction[];
private moveGroupRightActions: MoveGroupRightAction[];
private closeEditorsInGroupActions: CloseEditorsInGroupAction[];
......@@ -194,8 +195,17 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Close
this.closeEditorActions = POSITIONS.map((position) => this.instantiationService.createInstance(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL));
// Show Editors
this.showEditorsOfGroup = POSITIONS.map((position) => this.instantiationService.createInstance(ShowEditorsInGroupAction, ShowEditorsInGroupAction.ID, ShowEditorsInGroupAction.LABEL));
// Show Editors of Group
this.showEditorsOfGroup = POSITIONS.map((position) => {
switch (position) {
case Position.LEFT:
return this.instantiationService.createInstance(ShowEditorsInLeftGroupAction, ShowEditorsInLeftGroupAction.ID, ShowEditorsInLeftGroupAction.LABEL);
case Position.CENTER:
return this.instantiationService.createInstance(ShowEditorsInCenterGroupAction, ShowEditorsInCenterGroupAction.ID, ShowEditorsInCenterGroupAction.LABEL);
default:
return this.instantiationService.createInstance(ShowEditorsInRightGroupAction, ShowEditorsInRightGroupAction.ID, ShowEditorsInRightGroupAction.LABEL);
}
});
// Split
this.splitEditorAction = this.instantiationService.createInstance(SplitEditorAction, SplitEditorAction.ID, SplitEditorAction.LABEL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册