提交 7352ad52 编写于 作者: B Benjamin Pasero

rename positions (one, two, three)

上级 81a9436b
......@@ -111,17 +111,17 @@ export interface IEditor {
*/
export enum Position {
/** Opens the editor in the LEFT most position replacing the input currently showing */
LEFT = 0,
/** Opens the editor in the first position replacing the input currently showing */
ONE = 0,
/** Opens the editor in the CENTER position replacing the input currently showing */
CENTER = 1,
/** Opens the editor in the second position replacing the input currently showing */
TWO = 1,
/** Opens the editor in the RIGHT most position replacing the input currently showing */
RIGHT = 2
/** Opens the editor in the third most position replacing the input currently showing */
THREE = 2
}
export const POSITIONS = [Position.LEFT, Position.CENTER, Position.RIGHT];
export const POSITIONS = [Position.ONE, Position.TWO, Position.THREE];
export enum Direction {
LEFT,
......
......@@ -74,12 +74,12 @@ export class BaseTwoEditorsAction extends Action {
return this.createIfNotExists(editableResource, defaultEditableContents).then(() => {
return this.editorService.createInput({ resource: editableResource }).then(typedRightHandEditableInput => {
const editors = [
{ input: leftHandDefaultInput, position: Position.LEFT, options: { pinned: true } },
{ input: typedRightHandEditableInput, position: Position.CENTER, options: { pinned: true } }
{ input: leftHandDefaultInput, position: Position.ONE, options: { pinned: true } },
{ input: typedRightHandEditableInput, position: Position.TWO, options: { pinned: true } }
];
return this.editorService.openEditors(editors).then(() => {
this.editorGroupService.focusGroup(Position.CENTER);
this.editorGroupService.focusGroup(Position.TWO);
});
});
});
......@@ -153,7 +153,7 @@ export class OpenGlobalSettingsAction extends BaseOpenSettingsAction {
const editorCount = this.editorService.getVisibleEditors().length;
return this.editorService.createInput({ resource: this.contextService.toResource(WORKSPACE_CONFIG_DEFAULT_PATH) }).then(typedInput => {
return this.editorService.openEditor(typedInput, { pinned: true }, editorCount === 2 ? Position.RIGHT : editorCount === 1 ? Position.CENTER : void 0);
return this.editorService.openEditor(typedInput, { pinned: true }, editorCount === 2 ? Position.THREE : editorCount === 1 ? Position.TWO : void 0);
});
}),
new Action('neverShowAgain', nls.localize('neverShowAgain', "Don't show again"), null, true, () => {
......
......@@ -72,24 +72,24 @@ export class SplitEditorAction extends Action {
// Open split editor to the right of left one
case 1:
targetPosition = Position.CENTER;
targetPosition = Position.TWO;
break;
// Special case two editors opened
case 2:
// Continue splitting to the right
if (editorToSplit.position === Position.CENTER) {
targetPosition = Position.RIGHT;
if (editorToSplit.position === Position.TWO) {
targetPosition = Position.THREE;
}
// Push the center group to the right to make room for the splitted input
else if (editorToSplit.position === Position.LEFT) {
else if (editorToSplit.position === Position.ONE) {
options.preserveFocus = true;
return this.editorService.openEditor(editorToSplit.input, options, Position.RIGHT).then(() => {
this.editorGroupService.moveGroup(Position.RIGHT, Position.CENTER);
this.editorGroupService.focusGroup(Position.CENTER);
return this.editorService.openEditor(editorToSplit.input, options, Position.THREE).then(() => {
this.editorGroupService.moveGroup(Position.THREE, Position.TWO);
this.editorGroupService.focusGroup(Position.TWO);
});
}
}
......@@ -179,8 +179,8 @@ export class FocusFirstGroupAction extends Action {
// Find left editor and focus it
const editors = this.editorService.getVisibleEditors();
for (let editor of editors) {
if (editor.position === Position.LEFT) {
this.editorGroupService.focusGroup(Position.LEFT);
if (editor.position === Position.ONE) {
this.editorGroupService.focusGroup(Position.ONE);
return TPromise.as(true);
}
......@@ -193,10 +193,10 @@ export class FocusFirstGroupAction extends Action {
// For now only support to open files from history to the side
if (input instanceof EditorInput) {
if (!!getUntitledOrFileResource(input)) {
return this.editorService.openEditor(input, null, Position.LEFT);
return this.editorService.openEditor(input, null, Position.ONE);
}
} else {
return this.editorService.openEditor(input as IResourceInput, Position.LEFT);
return this.editorService.openEditor(input as IResourceInput, Position.ONE);
}
}
......@@ -293,11 +293,11 @@ export class FocusSecondGroupAction extends BaseFocusSideGroupAction {
}
protected getReferenceEditorSide(): Position {
return Position.LEFT;
return Position.ONE;
}
protected getTargetEditorSide(): Position {
return Position.CENTER;
return Position.TWO;
}
}
......@@ -317,11 +317,11 @@ export class FocusThirdGroupAction extends BaseFocusSideGroupAction {
}
protected getReferenceEditorSide(): Position {
return Position.CENTER;
return Position.TWO;
}
protected getTargetEditorSide(): Position {
return Position.RIGHT;
return Position.THREE;
}
}
......@@ -349,9 +349,9 @@ export class FocusPreviousGroup extends Action {
// Find the next position to the left
let nextPosition: Position = Position.LEFT;
if (activeEditor.position === Position.RIGHT) {
nextPosition = Position.CENTER;
let nextPosition: Position = Position.ONE;
if (activeEditor.position === Position.THREE) {
nextPosition = Position.TWO;
}
// Focus next position if provided
......@@ -377,9 +377,9 @@ export class FocusNextGroup extends Action {
super(id, label);
this.navigateActions = [];
this.navigateActions[Position.LEFT] = instantiationService.createInstance(FocusFirstGroupAction, FocusFirstGroupAction.ID, FocusFirstGroupAction.LABEL);
this.navigateActions[Position.CENTER] = instantiationService.createInstance(FocusSecondGroupAction, FocusSecondGroupAction.ID, FocusSecondGroupAction.LABEL);
this.navigateActions[Position.RIGHT] = instantiationService.createInstance(FocusThirdGroupAction, FocusThirdGroupAction.ID, FocusThirdGroupAction.LABEL);
this.navigateActions[Position.ONE] = instantiationService.createInstance(FocusFirstGroupAction, FocusFirstGroupAction.ID, FocusFirstGroupAction.LABEL);
this.navigateActions[Position.TWO] = instantiationService.createInstance(FocusSecondGroupAction, FocusSecondGroupAction.ID, FocusSecondGroupAction.LABEL);
this.navigateActions[Position.THREE] = instantiationService.createInstance(FocusThirdGroupAction, FocusThirdGroupAction.ID, FocusThirdGroupAction.LABEL);
}
public run(event?: any): TPromise<any> {
......@@ -388,11 +388,11 @@ export class FocusNextGroup extends Action {
let nextPosition: Position;
const activeEditor = this.editorService.getActiveEditor();
if (!activeEditor) {
nextPosition = Position.LEFT;
} else if (activeEditor.position === Position.LEFT) {
nextPosition = Position.CENTER;
} else if (activeEditor.position === Position.CENTER) {
nextPosition = Position.RIGHT;
nextPosition = Position.ONE;
} else if (activeEditor.position === Position.ONE) {
nextPosition = Position.TWO;
} else if (activeEditor.position === Position.TWO) {
nextPosition = Position.THREE;
}
// Run the action for the target next position
......@@ -419,7 +419,7 @@ export class OpenToSideAction extends Action {
private updateEnablement(): void {
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.RIGHT);
this.enabled = (!activeEditor || activeEditor.position !== Position.THREE);
}
public run(context: any): TPromise<any> {
......@@ -676,13 +676,13 @@ export class MoveGroupLeftAction extends Action {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && (activeEditor.position === Position.CENTER || activeEditor.position === Position.RIGHT)) {
if (activeEditor && (activeEditor.position === Position.TWO || activeEditor.position === Position.THREE)) {
position = activeEditor.position;
}
}
if (typeof position === 'number') {
const newPosition = (position === Position.CENTER) ? Position.LEFT : Position.CENTER;
const newPosition = (position === Position.TWO) ? Position.ONE : Position.TWO;
// Move group
this.editorGroupService.moveGroup(position, newPosition);
......@@ -712,13 +712,13 @@ export class MoveGroupRightAction extends Action {
const activeEditor = this.editorService.getActiveEditor();
const editors = this.editorService.getVisibleEditors();
if ((editors.length === 2 && activeEditor.position === Position.LEFT) || (editors.length === 3 && activeEditor.position !== Position.RIGHT)) {
if ((editors.length === 2 && activeEditor.position === Position.ONE) || (editors.length === 3 && activeEditor.position !== Position.THREE)) {
position = activeEditor.position;
}
}
if (typeof position === 'number') {
const newPosition = (position === Position.LEFT) ? Position.CENTER : Position.RIGHT;
const newPosition = (position === Position.ONE) ? Position.TWO : Position.THREE;
// Move group
this.editorGroupService.moveGroup(position, newPosition);
......@@ -1014,9 +1014,9 @@ export class ShowEditorsInGroupAction extends Action {
}
switch (stacks.positionOfGroup(context.group)) {
case Position.CENTER:
case Position.TWO:
return this.quickOpenService.show((groupCount === 2) ? NAVIGATE_IN_RIGHT_GROUP_PREFIX : NAVIGATE_IN_CENTER_GROUP_PREFIX);
case Position.RIGHT:
case Position.THREE:
return this.quickOpenService.show(NAVIGATE_IN_RIGHT_GROUP_PREFIX);
}
......@@ -1057,9 +1057,9 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
const count = stacks.groups.length;
let prefix = NAVIGATE_IN_LEFT_GROUP_PREFIX;
if (activePosition === Position.CENTER && count === 3) {
if (activePosition === Position.TWO && count === 3) {
prefix = NAVIGATE_IN_CENTER_GROUP_PREFIX;
} else if (activePosition === Position.RIGHT || (activePosition === Position.CENTER && count === 2)) {
} else if (activePosition === Position.THREE || (activePosition === Position.TWO && count === 2)) {
prefix = NAVIGATE_IN_RIGHT_GROUP_PREFIX;
}
......@@ -1238,7 +1238,7 @@ export class MoveEditorToLeftGroupAction extends Action {
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.position !== Position.LEFT) {
if (activeEditor && activeEditor.position !== Position.ONE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.position, activeEditor.position - 1);
}
......@@ -1262,7 +1262,7 @@ export class MoveEditorToRightGroupAction extends Action {
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.position !== Position.RIGHT) {
if (activeEditor && activeEditor.position !== Position.THREE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.position, activeEditor.position + 1);
}
......
......@@ -127,13 +127,13 @@ function moveActiveEditorToGroup(args: ActiveEditorMoveArguments, activeEditor:
newPosition = newPosition + 1;
break;
case ActiveEditorMovePositioning.FIRST:
newPosition = Position.LEFT;
newPosition = Position.ONE;
break;
case ActiveEditorMovePositioning.LAST:
newPosition = Position.RIGHT;
newPosition = Position.THREE;
break;
case ActiveEditorMovePositioning.CENTER:
newPosition = Position.CENTER;
newPosition = Position.TWO;
break;
case ActiveEditorMovePositioning.POSITION:
newPosition = args.value - 1;
......
......@@ -204,7 +204,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
// Opened to the side
if (position !== Position.LEFT) {
if (position !== Position.ONE) {
this.telemetryService.publicLog('workbenchSideEditorOpened', { position: position });
}
......@@ -915,13 +915,13 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
private doOpenEditors(editors: { input: EditorInput, position: Position, options?: EditorOptions }[], activePosition?: number, ratio?: number[]): TPromise<BaseEditor[]> {
const leftEditors = editors.filter(e => e.position === Position.LEFT);
const centerEditors = editors.filter(e => e.position === Position.CENTER);
const rightEditors = editors.filter(e => e.position === Position.RIGHT);
const leftEditors = editors.filter(e => e.position === Position.ONE);
const centerEditors = editors.filter(e => e.position === Position.TWO);
const rightEditors = editors.filter(e => e.position === Position.THREE);
const leftGroup = this.stacks.groupAt(Position.LEFT);
const centerGroup = this.stacks.groupAt(Position.CENTER);
const rightGroup = this.stacks.groupAt(Position.RIGHT);
const leftGroup = this.stacks.groupAt(Position.ONE);
const centerGroup = this.stacks.groupAt(Position.TWO);
const rightGroup = this.stacks.groupAt(Position.THREE);
// Compute the imaginary count if we const all editors open as the way requested
const leftCount = leftEditors.length + (leftGroup ? leftGroup.count : 0);
......@@ -938,7 +938,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Validate active input
if (typeof activePosition !== 'number') {
activePosition = Position.LEFT;
activePosition = Position.ONE;
}
// Validate ratios
......@@ -1173,7 +1173,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
const visibleEditors = this.getVisibleEditors();
const activeEditor = this.getActiveEditor();
if (visibleEditors.length === 0 || !activeEditor) {
return Position.LEFT; // can only be LEFT
return Position.ONE; // can only be LEFT
}
// Respect option to reveal an editor if it is already visible
......@@ -1193,17 +1193,17 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
if (types.isUndefinedOrNull(arg1) || arg1 === false) {
const lastActivePosition = this.sideBySideControl.getActivePosition();
return lastActivePosition || Position.LEFT;
return lastActivePosition || Position.ONE;
}
// Position is sideBySide: Find position relative to active editor
if (arg1 === true) {
switch (activeEditor.position) {
case Position.LEFT:
return Position.CENTER;
case Position.CENTER:
return Position.RIGHT;
case Position.RIGHT:
case Position.ONE:
return Position.TWO;
case Position.TWO:
return Position.THREE;
case Position.THREE:
return null; // Cannot open to the side of the right most editor
}
......@@ -1211,8 +1211,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
// Position is provided, validate it
if (arg1 === Position.RIGHT && visibleEditors.length === 1) {
return Position.CENTER;
if (arg1 === Position.THREE && visibleEditors.length === 1) {
return Position.TWO;
}
return arg1;
......@@ -1260,15 +1260,15 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
if (types.isUndefinedOrNull(arg2)) {
const rochade = <Rochade>arg1;
switch (rochade) {
case Rochade.CENTER_TO_LEFT:
this.rochade(Position.CENTER, Position.LEFT);
case Rochade.TWO_TO_ONE:
this.rochade(Position.TWO, Position.ONE);
break;
case Rochade.RIGHT_TO_CENTER:
this.rochade(Position.RIGHT, Position.CENTER);
case Rochade.THREE_TO_TWO:
this.rochade(Position.THREE, Position.TWO);
break;
case Rochade.CENTER_AND_RIGHT_TO_LEFT:
this.rochade(Position.CENTER, Position.LEFT);
this.rochade(Position.RIGHT, Position.CENTER);
case Rochade.TWO_AND_THREE_TO_ONE:
this.rochade(Position.TWO, Position.ONE);
this.rochade(Position.THREE, Position.TWO);
}
} else {
const from = <Position>arg1;
......@@ -1329,20 +1329,20 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// LEFT | CENTER | RIGHT
if (groups.length > 2) {
this.stacks.renameGroup(this.stacks.groupAt(Position.LEFT), EditorPart.GROUP_LEFT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.CENTER), EditorPart.GROUP_CENTER_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.RIGHT), EditorPart.GROUP_RIGHT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.ONE), EditorPart.GROUP_LEFT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.TWO), EditorPart.GROUP_CENTER_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.THREE), EditorPart.GROUP_RIGHT_LABEL);
}
// LEFT | RIGHT
else if (groups.length > 1) {
this.stacks.renameGroup(this.stacks.groupAt(Position.LEFT), EditorPart.GROUP_LEFT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.CENTER), EditorPart.GROUP_RIGHT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.ONE), EditorPart.GROUP_LEFT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.TWO), EditorPart.GROUP_RIGHT_LABEL);
}
// LEFT
else {
this.stacks.renameGroup(this.stacks.groupAt(Position.LEFT), EditorPart.GROUP_LEFT_LABEL);
this.stacks.renameGroup(this.stacks.groupAt(Position.ONE), EditorPart.GROUP_LEFT_LABEL);
}
}
}
......
......@@ -217,7 +217,7 @@ export abstract class EditorGroupPicker extends BaseEditorPicker {
export class LeftEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
return Position.LEFT;
return Position.ONE;
}
}
......@@ -226,7 +226,7 @@ export class CenterEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
const stacks = this.editorGroupService.getStacksModel();
return stacks.groups.length > 2 ? Position.CENTER : -1; // with 2 groups open, the center one is not available
return stacks.groups.length > 2 ? Position.TWO : -1; // with 2 groups open, the center one is not available
}
}
......@@ -235,7 +235,7 @@ export class RightEditorGroupPicker extends EditorGroupPicker {
protected getPosition(): Position {
const stacks = this.editorGroupService.getStacksModel();
return stacks.groups.length > 2 ? Position.RIGHT : Position.CENTER;
return stacks.groups.length > 2 ? Position.THREE : Position.TWO;
}
}
......
......@@ -257,7 +257,7 @@ export class ElectronIntegration {
return this.editorService.openEditors(resources.map((r, index) => {
return {
input: r,
position: activeEditor ? activeEditor.position : Position.LEFT
position: activeEditor ? activeEditor.position : Position.ONE
};
}));
});
......
......@@ -20,6 +20,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Registry } from 'vs/platform/platform';
import { isWindows, isLinux } from 'vs/base/common/platform';
import { IOptions } from 'vs/workbench/common/options';
import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IEditorRegistry, Extensions as EditorExtensions, TextEditorOptions, EditorInput, EditorOptions } from 'vs/workbench/common/editor';
......@@ -248,7 +249,7 @@ export class Workbench implements IPartService {
return {
input: inputWithOptions.input,
options: inputWithOptions.options,
position: Position.LEFT
position: EditorPosition.ONE
};
});
......
......@@ -217,7 +217,7 @@ class OpenExtensionToSideAction extends Action {
private updateEnablement(): void {
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.RIGHT);
this.enabled = (!activeEditor || activeEditor.position !== Position.THREE);
}
run(context: { extension: IExtension }): TPromise<any> {
......
......@@ -1175,7 +1175,7 @@ export class OpenToSideAction extends Action {
private updateEnablement(): void {
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.RIGHT);
this.enabled = (!activeEditor || activeEditor.position !== Position.THREE);
}
public run(): TPromise<any> {
......
......@@ -104,7 +104,7 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
this.pendingDirtyResources = [];
const activeEditor = this.editorService.getActiveEditor();
const activePosition = activeEditor ? activeEditor.position : Position.LEFT;
const activePosition = activeEditor ? activeEditor.position : Position.ONE;
// Open
this.editorService.openEditors(dirtyNotOpenedResources.map(resource => {
......
......@@ -290,7 +290,7 @@ suite('Workbench UI Services', () => {
assert(service.getVisibleEditors()[0] === editor);
});
service.openEditor(activeInput, null, Position.LEFT).then((editor) => {
service.openEditor(activeInput, null, Position.ONE).then((editor) => {
assert.strictEqual(openedEditorInput, activeInput);
assert.strictEqual(openedEditorOptions, null);
assert.strictEqual(editor, activeEditor);
......
......@@ -296,9 +296,9 @@ suite('Editor Stacks Model', () => {
const group2 = model.openGroup('second');
const group3 = model.openGroup('third');
assert.equal(Position.LEFT, model.positionOfGroup(group1));
assert.equal(Position.CENTER, model.positionOfGroup(group2));
assert.equal(Position.RIGHT, model.positionOfGroup(group3));
assert.equal(Position.ONE, model.positionOfGroup(group1));
assert.equal(Position.TWO, model.positionOfGroup(group2));
assert.equal(Position.THREE, model.positionOfGroup(group3));
});
test('Groups - Rename Group', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册