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

grid - use group identifier in IEditorIdentifier

上级 1e2e8fb3
......@@ -126,7 +126,7 @@ export class BaseSplitEditorGroupAction extends Action {
public run(context?: IEditorIdentifier): TPromise<any> {
let group: INextEditorGroup;
if (context && context.group) {
group = this.nextEditorGroupsService.getGroup(context.group.id);
group = this.nextEditorGroupsService.getGroup(context.group);
}
if (!group) {
......@@ -238,7 +238,7 @@ export class JoinTwoGroupsAction extends Action {
// Joining group is from context, or the active group
if (context) {
fromPosition = editorStacksModel.positionOfGroup(context.group);
fromPosition = editorStacksModel.positionOfGroup(editorStacksModel.getGroup(context.group));
} else {
fromPosition = editorStacksModel.positionOfGroup(editorStacksModel.activeGroup);
}
......@@ -809,7 +809,7 @@ export class CloseEditorsInOtherGroupsAction extends Action {
}
public run(context?: IEditorIdentifier): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(this.editorGroupService.getStacksModel().getGroup(context.group)) : null;
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
......@@ -840,7 +840,7 @@ export class MoveGroupLeftAction extends Action {
}
public run(context?: IEditorIdentifier): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(this.editorGroupService.getStacksModel().getGroup(context.group)) : null;
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && (activeEditor.group === Position.TWO || activeEditor.group === Position.THREE)) {
......@@ -874,7 +874,7 @@ export class MoveGroupRightAction extends Action {
}
public run(context?: IEditorIdentifier): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(this.editorGroupService.getStacksModel().getGroup(context.group)) : null;
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
const editors = this.editorService.getVisibleEditors();
......@@ -955,7 +955,7 @@ export class MaximizeGroupAction extends Action {
function getTarget(editorService: IWorkbenchEditorService, editorGroupService: IEditorGroupService, context?: IEditorIdentifier): { input: IEditorInput, position: Position } {
if (context) {
return { input: context.editor, position: editorGroupService.getStacksModel().positionOfGroup(context.group) };
return { input: context.editor, position: editorGroupService.getStacksModel().positionOfGroup(editorGroupService.getStacksModel().getGroup(context.group)) };
}
const activeEditor = editorService.getActiveEditor();
......@@ -981,7 +981,7 @@ export abstract class BaseNavigateEditorAction extends Action {
const model = this.editorGroupService.getStacksModel();
const result = this.navigate();
if (result) {
return this.editorService.openEditor(result.editor, null, model.positionOfGroup(result.group));
return this.editorService.openEditor(result.editor, null, model.positionOfGroup(this.editorGroupService.getStacksModel().getGroup(result.group)));
}
return TPromise.as(false);
......
......@@ -276,7 +276,7 @@ function registerEditorCommands() {
const editorGroupService = accessor.get(IEditorGroupService);
const model = editorGroupService.getStacksModel();
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
if (contexts.length === 0 && model.activeGroup) {
// If command is triggered from the command palette use the active group
contexts.push({ groupId: model.activeGroup.id });
......@@ -305,7 +305,7 @@ function registerEditorCommands() {
handler: (accessor, resource: URI | object, context: IEditorCommandsContext) => {
const editorGroupService = accessor.get(IEditorGroupService);
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const distinctGroupIds = distinct(contexts.map(c => c.groupId));
const model = editorGroupService.getStacksModel();
......@@ -332,7 +332,7 @@ function registerEditorCommands() {
const editorService = accessor.get(IWorkbenchEditorService);
const nextEditorGroupService = accessor.get(INextEditorGroupsService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const groupIds = distinct(contexts.map(context => context.groupId));
const model = editorGroupService.getStacksModel();
......@@ -391,7 +391,7 @@ function registerEditorCommands() {
handler: (accessor, resource: URI | object, context: IEditorCommandsContext) => {
const editorGroupService = accessor.get(IEditorGroupService);
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const model = editorGroupService.getStacksModel();
if (contexts.length === 0) {
......@@ -533,12 +533,13 @@ function positionAndInput(editorGroupService: IEditorGroupService, editorService
return { position, input };
}
export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsContext, listService: IListService): IEditorCommandsContext[] {
export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsContext, listService: IListService, editorGroupService: IEditorGroupService): IEditorCommandsContext[] {
const stacks = editorGroupService.getStacksModel();
// First check for a focused list to return the selected items from
const list = listService.lastFocusedList;
if (list instanceof List && list.isDOMFocused()) {
const elementToContext = (element: IEditorIdentifier | EditorGroup) =>
element instanceof EditorGroup ? { groupId: element.id, editorIndex: undefined } : { groupId: element.group.id, editorIndex: element.group.indexOf(element.editor) };
element instanceof EditorGroup ? { groupId: element.id, editorIndex: undefined } : { groupId: element.group, editorIndex: stacks.getGroup(element.group).indexOf(element.editor) };
const onlyEditorGroupAndEditor = (e: IEditorIdentifier | EditorGroup) => e instanceof EditorGroup || ('editor' in e && 'group' in e);
const focusedElements: (IEditorIdentifier | EditorGroup)[] = list.getFocusedElements().filter(onlyEditorGroupAndEditor);
......@@ -548,7 +549,7 @@ export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsCon
if (focus) {
const selection: (IEditorIdentifier | EditorGroup)[] = list.getSelectedElements().filter(onlyEditorGroupAndEditor);
// Only respect selection if it contains focused element
if (selection && selection.some(s => s instanceof EditorGroup ? s.id === focus.groupId : s.group.id === focus.groupId && s.group.indexOf(s.editor) === focus.editorIndex)) {
if (selection && selection.some(s => s instanceof EditorGroup ? s.id === focus.groupId : s.group === focus.groupId && stacks.getGroup(s.group).indexOf(s.editor) === focus.editorIndex)) {
return selection.map(elementToContext);
}
......
......@@ -1135,7 +1135,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
let options = EditorOptions.create({ pinned: true });
const activeEditor = $this.editorService.getActiveEditor();
const editor = getCodeEditor(activeEditor);
if (editor && activeEditor.group === stacks.positionOfGroup(identifier.group) && identifier.editor.matches(activeEditor.input)) {
if (editor && activeEditor.group === stacks.positionOfGroup(stacks.getGroup(identifier.group)) && identifier.editor.matches(activeEditor.input)) {
options = TextEditorOptions.fromEditor(editor, { pinned: true });
}
......@@ -1181,16 +1181,17 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
// Move editor to new location
else {
const sourcePosition = stacks.positionOfGroup(draggedEditor.group);
const draggedGroup = stacks.getGroup(draggedEditor.group);
const sourcePosition = stacks.positionOfGroup(draggedGroup);
if (splitEditor) {
if (draggedEditor.group.count === 1) {
if (draggedGroup.count === 1) {
groupService.moveGroup(sourcePosition, splitTo);
} else {
editorService.openEditor(draggedEditor.editor, optionsFromDraggedEditor(draggedEditor), freeGroup).then(() => {
if (splitTo !== freeGroup) {
groupService.moveGroup(freeGroup, splitTo);
}
groupService.moveEditor(draggedEditor.editor, stacks.positionOfGroup(draggedEditor.group), splitTo);
groupService.moveEditor(draggedEditor.editor, stacks.positionOfGroup(draggedGroup), splitTo);
}).done(null, errors.onUnexpectedError);
}
......@@ -1228,14 +1229,16 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
let splitTarget: Position;
const draggedGroup = stacks.getGroup(draggedEditor.group);
// No splitting if we reached maximum group count
if (groups === POSITIONS.length) {
splitTarget = null;
}
// Special splitting if we drag an editor of a group with only one editor
else if (!isCopy && draggedEditor && draggedEditor.group.count === 1) {
const positionOfDraggedEditor = stacks.positionOfGroup(draggedEditor.group);
else if (!isCopy && draggedEditor && draggedGroup.count === 1) {
const positionOfDraggedEditor = stacks.positionOfGroup(draggedGroup);
switch (positionOfDraggedEditor) {
case Position.ONE:
if (position === Position.TWO && isOverSplitRightOrBottom) {
......
......@@ -20,7 +20,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Scope as MementoScope } from 'vs/workbench/common/memento';
import { Part } from 'vs/workbench/browser/part';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisibleContext, TEXT_DIFF_EDITOR_ID, EditorOpeningEvent, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisibleContext, TEXT_DIFF_EDITOR_ID, EditorOpeningEvent, IEditorOpeningEvent, GroupIdentifier } from 'vs/workbench/common/editor';
import { EditorGroupsControl, Rochade, IEditorGroupsControl, ProgressState } from 'vs/workbench/browser/parts/editor/editorGroupsControl';
import { ScopedProgressService } from 'vs/workbench/services/progress/browser/progressService';
import { IEditorGroupService, GroupOrientation, GroupArrangement, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
......@@ -189,7 +189,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
editor.options = EditorOptions.create({ index });
}
const replacement = { group, editor: editor.toReplace, replaceWith: editor.replaceWith, options: editor.options };
const replacement = { group: group.id, editor: editor.toReplace, replaceWith: editor.replaceWith, options: editor.options };
if (group.activeEditor.matches(editor.toReplace)) {
activeReplacements.push(replacement);
} else {
......@@ -202,7 +202,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Deal with hidden replacements first
hiddenReplacements.forEach(replacement => {
const group = replacement.group;
const group = this.stacks.getGroup(replacement.group);
group.openEditor(replacement.replaceWith, { active: false, pinned: true, index: replacement.options.index });
group.closeEditor(replacement.editor);
......@@ -210,7 +210,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Now deal with active editors to be opened
const res = this.openEditors(activeReplacements.map(replacement => {
const group = replacement.group;
const group = this.stacks.getGroup(replacement.group);
return {
input: replacement.replaceWith,
......@@ -221,7 +221,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Close active editors to be replaced now (they are no longer active)
activeReplacements.forEach(replacement => {
this.doCloseEditor(replacement.group, replacement.editor, false);
this.doCloseEditor(this.stacks.getGroup(replacement.group), replacement.editor, false);
});
return res;
......@@ -301,7 +301,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Check for dirty and veto
const ignoreDirtyIfOpenedInOtherGroup = (groups.length === 1);
return this.handleDirty(arrays.flatten(groups.map(group => group.getEditors(true /* in MRU order */).map(editor => ({ group, editor })))), ignoreDirtyIfOpenedInOtherGroup).then(veto => {
return this.handleDirty(arrays.flatten(groups.map(group => group.getEditors(true /* in MRU order */).map(editor => ({ group: group.id, editor })))), ignoreDirtyIfOpenedInOtherGroup).then(veto => {
if (veto) {
return;
}
......@@ -384,7 +384,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
}
return { group, editorsToClose: editorsToClose.map(editor => ({ editor, group })), filter };
return { group: group.id, editorsToClose: editorsToClose.map(editor => ({ editor, group: group.id })), filter } as any;
}
private doCloseEditors(group: EditorGroup, editors: EditorInput[]): void {
......@@ -799,20 +799,20 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this.pendingEditorInputsToClose.forEach(identifier => {
const { group, editor } = identifier;
if (group.isActive(editor)) {
if (this.stacks.getGroup(group).isActive(editor)) {
visibleEditors.push(identifier);
} else if (group.contains(editor)) {
} else if (this.stacks.getGroup(group).contains(editor)) {
hiddenEditors.push(identifier);
}
});
// Close all hidden first
hiddenEditors.forEach(hidden => this.doCloseEditor(<EditorGroup>hidden.group, hidden.editor, false));
hiddenEditors.forEach(hidden => this.doCloseEditor(this.stacks.getGroup(hidden.group), hidden.editor, false));
// Close visible ones second
visibleEditors
.sort((a1, a2) => this.stacks.positionOfGroup(a2.group) - this.stacks.positionOfGroup(a1.group)) // reduce layout work by starting right/bottom first
.forEach(visible => this.doCloseEditor(<EditorGroup>visible.group, visible.editor, false));
.sort((a1, a2) => this.stacks.positionOfGroup(this.stacks.getGroup(a2.group)) - this.stacks.positionOfGroup(this.stacks.getGroup(a1.group))) // reduce layout work by starting right/bottom first
.forEach(visible => this.doCloseEditor(this.stacks.getGroup(visible.group), visible.editor, false));
// Reset
this.pendingEditorInputCloseTimeout = null;
......@@ -1240,7 +1240,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
// Check for dirty and veto
return this.handleDirty([{ group, editor: input }], true /* ignore if opened in other group */).then(veto => {
return this.handleDirty([{ group: group.id, editor: input }], true /* ignore if opened in other group */).then(veto => {
if (veto) {
return;
}
......@@ -1356,7 +1356,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
const { editor } = identifier;
// Switch to editor that we want to handle
return this.openEditor(identifier.editor, null, this.stacks.positionOfGroup(identifier.group)).then(() => {
return this.openEditor(identifier.editor, null, this.stacks.positionOfGroup(this.stacks.getGroup(identifier.group))).then(() => {
return editor.confirmSave().then(res => {
// It could be that the editor saved meanwhile, so we check again
......@@ -1742,7 +1742,7 @@ interface IEditorPartUIState {
}
interface IEditorReplacement extends EditorIdentifier {
group: EditorGroup;
group: GroupIdentifier;
editor: EditorInput;
replaceWith: EditorInput;
options?: EditorOptions;
......
......@@ -154,7 +154,7 @@ class DropOverlay extends Themable {
// Check for editor transfer
else if (this.editorTransfer.hasData(DraggedEditorIdentifier.prototype)) {
return this.accessor.getGroup(this.editorTransfer.getData(DraggedEditorIdentifier.prototype)[0].identifier.group.id);
return this.accessor.getGroup(this.editorTransfer.getData(DraggedEditorIdentifier.prototype)[0].identifier.group);
}
return void 0;
......@@ -213,7 +213,7 @@ class DropOverlay extends Themable {
const targetGroup = ensureTargetGroup();
// Return if the drop is a no-op
const sourceGroup = this.accessor.getGroup(draggedEditor.group.id);
const sourceGroup = this.accessor.getGroup(draggedEditor.group);
if (sourceGroup === targetGroup) {
return;
}
......
......@@ -584,7 +584,7 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
openEditor(editor: EditorInput, options?: EditorOptions): Thenable<void> {
// Editor opening event allows for prevention
const event = new EditorOpeningEvent(this, editor, options);
const event = new EditorOpeningEvent(this._group.id, editor, options);
this._onWillOpenEditor.fire(event);
const prevented = event.isPrevented();
if (prevented) {
......
......@@ -11,7 +11,7 @@ import { isMacintosh } from 'vs/base/common/platform';
import { shorten } from 'vs/base/common/labels';
import { ActionRunner, IAction } from 'vs/base/common/actions';
import { IEditorInput, Verbosity } from 'vs/platform/editor/common/editor';
import { IEditorGroup, toResource, GroupIdentifier } from 'vs/workbench/common/editor';
import { toResource, GroupIdentifier } from 'vs/workbench/common/editor';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { EventType as TouchEventType, GestureEvent, Gesture } from 'vs/base/browser/touch';
import { KeyCode } from 'vs/base/common/keyCodes';
......@@ -181,7 +181,7 @@ export class NextTabsTitleControl extends NextTitleControl {
isLocalDragAndDrop = true;
const localDraggedEditor = this.editorTransfer.getData(DraggedEditorIdentifier.prototype)[0].identifier;
if (this.group.id === localDraggedEditor.group.id && this.group.getIndexOfEditor(localDraggedEditor.editor) === this.group.count - 1) {
if (this.group.id === localDraggedEditor.group && this.group.getIndexOfEditor(localDraggedEditor.editor) === this.group.count - 1) {
e.dataTransfer.dropEffect = 'none';
return;
}
......@@ -526,7 +526,7 @@ export class NextTabsTitleControl extends NextTitleControl {
// Drag support
disposables.push(addDisposableListener(tab, EventType.DRAG_START, (e: DragEvent) => {
const editor = this.group.getEditor(index);
this.editorTransfer.setData([new DraggedEditorIdentifier({ editor, group: (<any>this.group /* TODO@grid should be GroupIdentifier or INextEditorGroup */).group })], DraggedEditorIdentifier.prototype);
this.editorTransfer.setData([new DraggedEditorIdentifier({ editor, group: this.group.id })], DraggedEditorIdentifier.prototype);
e.dataTransfer.effectAllowed = 'copyMove';
......@@ -560,7 +560,7 @@ export class NextTabsTitleControl extends NextTitleControl {
isLocalDragAndDrop = true;
const localDraggedEditor = this.editorTransfer.getData(DraggedEditorIdentifier.prototype)[0].identifier;
if (localDraggedEditor.editor === this.group.getEditor(index) && localDraggedEditor.group.id === this.group.id) {
if (localDraggedEditor.editor === this.group.getEditor(index) && localDraggedEditor.group === this.group.id) {
e.dataTransfer.dropEffect = 'none';
return;
}
......@@ -967,7 +967,7 @@ export class NextTabsTitleControl extends NextTitleControl {
// Local DND
const draggedEditor = this.editorTransfer.hasData(DraggedEditorIdentifier.prototype) ? this.editorTransfer.getData(DraggedEditorIdentifier.prototype)[0].identifier : void 0;
if (draggedEditor) {
const sourceGroup = this.accessor.getGroup(draggedEditor.group.id) as INextEditorGroup;
const sourceGroup = this.accessor.getGroup(draggedEditor.group);
// Move editor to target position and index
if (this.isMoveOperation(e, draggedEditor.group)) {
......@@ -990,10 +990,10 @@ export class NextTabsTitleControl extends NextTitleControl {
}
}
private isMoveOperation(e: DragEvent, source: IEditorGroup) {
private isMoveOperation(e: DragEvent, source: GroupIdentifier) {
const isCopy = (e.ctrlKey && !isMacintosh) || (e.altKey && isMacintosh);
return !isCopy || source.id === this.group.id;
return !isCopy || source === this.group.id;
}
dispose(): void {
......
......@@ -273,10 +273,8 @@ export abstract class EditorInput implements IEditorInput {
}
}
export interface IEditorOpeningEvent {
editor: IEditorInput;
export interface IEditorOpeningEvent extends IEditorIdentifier {
options?: IEditorOptions;
group: INextEditorGroup;
/**
* Allows to prevent the opening of an editor by providing a callback
......@@ -291,10 +289,10 @@ export interface IEditorOpeningEvent {
export class EditorOpeningEvent implements IEditorOpeningEvent {
private override: () => Thenable<any>;
constructor(private _group: INextEditorGroup, private _editor: IEditorInput, private _options: IEditorOptions) {
constructor(private _group: GroupIdentifier, private _editor: IEditorInput, private _options: IEditorOptions) {
}
public get group(): INextEditorGroup {
public get group(): GroupIdentifier {
return this._group;
}
......@@ -805,7 +803,7 @@ export interface IEditorGroup {
}
export interface IEditorIdentifier {
group: IEditorGroup; // TODO@grid this should be the group identifier instead
group: GroupIdentifier;
editor: IEditorInput;
}
......
......@@ -22,7 +22,7 @@ export interface EditorCloseEvent extends IEditorCloseEvent {
}
export interface EditorIdentifier extends IEditorIdentifier {
group: EditorGroup;
group: GroupIdentifier;
editor: EditorInput;
}
......@@ -348,7 +348,7 @@ export class EditorGroup extends Disposable implements IEditorGroup {
this.splice(index, true);
// Event
return { editor, replaced, index, group: this };
return { editor, replaced, index, group: this.id };
}
closeEditors(except: EditorInput, direction?: Direction): void {
......@@ -984,7 +984,7 @@ export class EditorStacksModel implements IEditorStacksModel {
// Return next in group
if (index + 1 < this.activeGroup.count) {
return { group: this.activeGroup, editor: this.activeGroup.getEditor(index + 1) };
return { group: this.activeGroup.id, editor: this.activeGroup.getEditor(index + 1) };
}
// Return first if we are not jumping groups
......@@ -992,14 +992,14 @@ export class EditorStacksModel implements IEditorStacksModel {
if (!cycleAtEnd) {
return null;
}
return { group: this.activeGroup, editor: this.activeGroup.getEditor(0) };
return { group: this.activeGroup.id, editor: this.activeGroup.getEditor(0) };
}
// Return first in next group
const indexOfGroup = this.indexOf(this.activeGroup);
const nextGroup = this.groups[indexOfGroup + 1];
if (nextGroup) {
return { group: nextGroup, editor: nextGroup.getEditor(0) };
return { group: nextGroup.id, editor: nextGroup.getEditor(0) };
}
// Return null if we are not cycling at the end
......@@ -1009,7 +1009,7 @@ export class EditorStacksModel implements IEditorStacksModel {
// Return first in first group
const firstGroup = this.groups[0];
return { group: firstGroup, editor: firstGroup.getEditor(0) };
return { group: firstGroup.id, editor: firstGroup.getEditor(0) };
}
previous(jumpGroups: boolean, cycleAtStart = true): IEditorIdentifier {
......@@ -1023,7 +1023,7 @@ export class EditorStacksModel implements IEditorStacksModel {
// Return previous in group
if (index > 0) {
return { group: this.activeGroup, editor: this.activeGroup.getEditor(index - 1) };
return { group: this.activeGroup.id, editor: this.activeGroup.getEditor(index - 1) };
}
// Return last if we are not jumping groups
......@@ -1031,14 +1031,14 @@ export class EditorStacksModel implements IEditorStacksModel {
if (!cycleAtStart) {
return null;
}
return { group: this.activeGroup, editor: this.activeGroup.getEditor(this.activeGroup.count - 1) };
return { group: this.activeGroup.id, editor: this.activeGroup.getEditor(this.activeGroup.count - 1) };
}
// Return last in previous group
const indexOfGroup = this.indexOf(this.activeGroup);
const previousGroup = this.groups[indexOfGroup - 1];
if (previousGroup) {
return { group: previousGroup, editor: previousGroup.getEditor(previousGroup.count - 1) };
return { group: previousGroup.id, editor: previousGroup.getEditor(previousGroup.count - 1) };
}
// Return null if we are not cycling at the start
......@@ -1048,7 +1048,7 @@ export class EditorStacksModel implements IEditorStacksModel {
// Return last in last group
const lastGroup = this.groups[this.groups.length - 1];
return { group: lastGroup, editor: lastGroup.getEditor(lastGroup.count - 1) };
return { group: lastGroup.id, editor: lastGroup.getEditor(lastGroup.count - 1) };
}
last(): IEditorIdentifier {
......@@ -1058,7 +1058,7 @@ export class EditorStacksModel implements IEditorStacksModel {
return null;
}
return { group: this.activeGroup, editor: this.activeGroup.getEditor(this.activeGroup.count - 1) };
return { group: this.activeGroup.id, editor: this.activeGroup.getEditor(this.activeGroup.count - 1) };
}
private save(): void {
......@@ -1168,15 +1168,15 @@ export class EditorStacksModel implements IEditorStacksModel {
unbind.push(group.onDidEditorLabelChange(editor => this._onModelChanged.fire({ group, editor })));
unbind.push(group.onDidEditorPin(editor => this._onModelChanged.fire({ group, editor })));
unbind.push(group.onDidEditorUnpin(editor => this._onModelChanged.fire({ group, editor })));
unbind.push(group.onDidEditorOpen(editor => this._onEditorOpened.fire({ editor, group })));
unbind.push(group.onDidEditorOpen(editor => this._onEditorOpened.fire({ editor, group: group.id })));
unbind.push(group.onDidEditorClose(event => {
this._onWillCloseEditor.fire(event);
this.handleOnEditorClosed(event);
this._onEditorClosed.fire(event);
}));
unbind.push(group.onDidEditorDispose(editor => this._onEditorDisposed.fire({ editor, group })));
unbind.push(group.onDidEditorBecomeDirty(editor => this._onEditorDirty.fire({ editor, group })));
unbind.push(group.onDidEditorLabelChange(editor => this._onEditorLabelChange.fire({ editor, group })));
unbind.push(group.onDidEditorDispose(editor => this._onEditorDisposed.fire({ editor, group: group.id })));
unbind.push(group.onDidEditorBecomeDirty(editor => this._onEditorDirty.fire({ editor, group: group.id })));
unbind.push(group.onDidEditorLabelChange(editor => this._onEditorLabelChange.fire({ editor, group: group.id })));
unbind.push(this.onGroupClosed(g => {
if (g === group) {
dispose(unbind);
......
......@@ -14,7 +14,7 @@ import { Action } from 'vs/base/common/actions';
import { VIEWLET_ID, IExplorerViewlet, TEXT_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
import { ITextFileEditorModel, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
import { EditorOptions, TextEditorOptions, IEditorCloseEvent } from 'vs/workbench/common/editor';
import { EditorOptions, TextEditorOptions, IEditorIdentifier } from 'vs/workbench/common/editor';
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
......@@ -31,6 +31,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ScrollType } from 'vs/editor/common/editorCommon';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
/**
* An implementation of editor for file system resources.
......@@ -48,6 +49,7 @@ export class TextFileEditor extends BaseTextEditor {
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService nextEditorService: INextEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@ITextFileService textFileService: ITextFileService,
......@@ -60,7 +62,7 @@ export class TextFileEditor extends BaseTextEditor {
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
// React to editors closing to preserve view state
this.toUnbind.push(editorGroupService.getStacksModel().onWillCloseEditor(e => this.onWillCloseEditor(e)));
this.toUnbind.push(nextEditorService.onWillCloseEditor(e => this.onWillCloseEditor(e)));
}
private onFilesChanged(e: FileChangesEvent): void {
......@@ -70,8 +72,8 @@ export class TextFileEditor extends BaseTextEditor {
}
}
private onWillCloseEditor(e: IEditorCloseEvent): void {
if (e.editor === this.input && this.group === this.editorGroupService.getStacksModel().positionOfGroup(e.group)) {
private onWillCloseEditor(e: IEditorIdentifier): void {
if (e.editor === this.input && this.group === e.group) {
this.doSaveTextEditorViewState(this.input);
}
}
......
......@@ -451,19 +451,23 @@ export class OpenEditor implements IEditorIdentifier {
}
public get editorIndex() {
return this._group.indexOf(this.editor);
return this.legacyGroup.indexOf(this.editor);
}
public get group() {
return this._group.id;
}
public get legacyGroup() {
return this._group;
}
public getId(): string {
return `openeditor:${this.group.id}:${this.group.indexOf(this.editor)}:${this.editor.getName()}:${this.editor.getDescription()}`;
return `openeditor:${this.group}:${this.legacyGroup.indexOf(this.editor)}:${this.editor.getName()}:${this.editor.getDescription()}`;
}
public isPreview(): boolean {
return this.group.isPreview(this.editor);
return this.legacyGroup.isPreview(this.editor);
}
public isUntitled(): boolean {
......
......@@ -528,7 +528,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry.registerCommand({
id: SAVE_ALL_IN_GROUP_COMMAND_ID,
handler: (accessor, resource: URI | object, editorContext: IEditorCommandsContext) => {
const contexts = getMultiSelectedEditorContexts(editorContext, accessor.get(IListService));
const contexts = getMultiSelectedEditorContexts(editorContext, accessor.get(IListService), accessor.get(IEditorGroupService));
const editorGroupService = accessor.get(IEditorGroupService);
let saveAllArg: any;
if (!contexts.length) {
......
......@@ -199,7 +199,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
const element = focused.length ? focused[0] : undefined;
if (element instanceof OpenEditor) {
if (isMiddleClick) {
const position = this.model.positionOfGroup(element.group);
const position = this.model.positionOfGroup(element.legacyGroup);
this.editorService.closeEditor(position, element.editor).done(null, errors.onUnexpectedError);
} else {
this.openEditor(element, { preserveFocus: isSingleClick, pinned: isDoubleClick, sideBySide: openToSide });
......@@ -291,7 +291,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
*/
this.telemetryService.publicLog('workbenchActionExecuted', { id: 'workbench.files.openFile', from: 'openEditors' });
let position = this.model.positionOfGroup(element.group);
let position = this.model.positionOfGroup(element.legacyGroup);
if (options.sideBySide && position !== Position.THREE) {
position++;
}
......@@ -317,7 +317,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
fillInActions(this.contributedContextMenu, { shouldForwardArgs: true, arg: element instanceof OpenEditor ? element.editor.getResource() : {} }, actions, this.contextMenuService);
return TPromise.as(actions);
},
getActionsContext: () => element instanceof OpenEditor ? { groupId: element.group.id, editorIndex: element.editorIndex } : { groupId: element.id }
getActionsContext: () => element instanceof OpenEditor ? { groupId: element.group, editorIndex: element.editorIndex } : { groupId: element.id }
});
}
......@@ -493,7 +493,7 @@ class EditorGroupRenderer implements IRenderer<IEditorGroup, IEditorGroupTemplat
if (this.transfer.hasData(OpenEditor.prototype)) {
this.transfer.getData(OpenEditor.prototype).forEach(oe =>
this.editorGroupService.moveEditor(oe.editor, model.positionOfGroup(oe.group), positionOfTargetGroup, { preserveFocus: true }));
this.editorGroupService.moveEditor(oe.editor, model.positionOfGroup(oe.legacyGroup), positionOfTargetGroup, { preserveFocus: true }));
this.editorGroupService.activateGroup(positionOfTargetGroup);
} else {
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: false });
......@@ -575,12 +575,12 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
editorTemplate.toDispose.push(dom.addDisposableListener(container, dom.EventType.DROP, (e: DragEvent) => {
dom.removeClass(container, 'focused');
const model = this.editorGroupService.getStacksModel();
const positionOfTargetGroup = model.positionOfGroup(editorTemplate.openEditor.group);
const index = editorTemplate.openEditor.group.indexOf(editorTemplate.openEditor.editor);
const positionOfTargetGroup = model.positionOfGroup(editorTemplate.openEditor.legacyGroup);
const index = editorTemplate.openEditor.legacyGroup.indexOf(editorTemplate.openEditor.editor);
if (this.transfer.hasData(OpenEditor.prototype)) {
this.transfer.getData(OpenEditor.prototype).forEach((oe, offset) =>
this.editorGroupService.moveEditor(oe.editor, model.positionOfGroup(oe.group), positionOfTargetGroup, { index: index + offset, preserveFocus: true }));
this.editorGroupService.moveEditor(oe.editor, model.positionOfGroup(oe.legacyGroup), positionOfTargetGroup, { index: index + offset, preserveFocus: true }));
this.editorGroupService.activateGroup(positionOfTargetGroup);
} else {
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: false });
......@@ -602,7 +602,7 @@ class OpenEditorRenderer implements IRenderer<OpenEditor, IOpenEditorTemplateDat
extraClasses: ['open-editor'],
fileDecorations: this.configurationService.getValue<IFilesConfiguration>().explorer.decorations
});
templateData.actionBar.context = { groupId: editor.group.id, editorIndex: editor.editorIndex };
templateData.actionBar.context = { groupId: editor.group, editorIndex: editor.editorIndex };
}
disposeTemplate(templateData: IOpenEditorTemplateData): void {
......
......@@ -21,6 +21,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
const schemaRegistry = Registry.as<JSONContributionRegistry.IJSONContributionRegistry>(JSONContributionRegistry.Extensions.JSONContribution);
......@@ -34,6 +35,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
@IPreferencesService private preferencesService: IPreferencesService,
@IModeService private modeService: IModeService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@INextEditorGroupsService private nextEditorGroupService: INextEditorGroupsService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWorkspaceContextService private workspaceService: IWorkspaceContextService,
@IConfigurationService private configurationService: IConfigurationService
......@@ -72,13 +74,14 @@ export class PreferencesContribution implements IWorkbenchContribution {
// If the file resource was already opened before in the group, do not prevent
// the opening of that resource. Otherwise we would have the same settings
// opened twice (https://github.com/Microsoft/vscode/issues/36447)
if (event.group.isOpened(event.editor)) {
const group = this.nextEditorGroupService.getGroup(event.group);
if (group.isOpened(event.editor)) {
return;
}
// Global User Settings File
if (resource.fsPath === this.environmentService.appSettingsPath) {
return event.prevent(() => this.preferencesService.openGlobalSettings(event.options, event.group));
return event.prevent(() => this.preferencesService.openGlobalSettings(event.options, group));
}
// Single Folder Workspace Settings File
......@@ -86,7 +89,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
if (state === WorkbenchState.FOLDER) {
const folders = this.workspaceService.getWorkspace().folders;
if (resource.fsPath === folders[0].toResource(FOLDER_SETTINGS_PATH).fsPath) {
return event.prevent(() => this.preferencesService.openWorkspaceSettings(event.options, event.group));
return event.prevent(() => this.preferencesService.openWorkspaceSettings(event.options, group));
}
}
......@@ -95,7 +98,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
const folders = this.workspaceService.getWorkspace().folders;
for (let i = 0; i < folders.length; i++) {
if (resource.fsPath === folders[i].toResource(FOLDER_SETTINGS_PATH).fsPath) {
return event.prevent(() => this.preferencesService.openFolderSettings(folders[i].uri, event.options, event.group));
return event.prevent(() => this.preferencesService.openFolderSettings(folders[i].uri, event.options, group));
}
}
}
......
......@@ -7,7 +7,7 @@
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, ITextEditorOptions, IEditorOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, IFileInputFactory, EditorInput, SideBySideEditorInput, IEditorInputWithOptions, isEditorInputWithOptions, EditorOptions, TextEditorOptions, IEditorOpeningEvent } from 'vs/workbench/common/editor';
import { GroupIdentifier, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorExtensions, IFileInputFactory, EditorInput, SideBySideEditorInput, IEditorInputWithOptions, isEditorInputWithOptions, EditorOptions, TextEditorOptions, IEditorOpeningEvent, IEditorIdentifier } from 'vs/workbench/common/editor';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -48,14 +48,17 @@ export class NextEditorService extends Disposable implements INextEditorService
private _onDidVisibleEditorsChange: Emitter<void> = this._register(new Emitter<void>());
get onDidVisibleEditorsChange(): Event<void> { return this._onDidVisibleEditorsChange.event; }
private _onDidCloseEditor: Emitter<IEditorInput> = this._register(new Emitter<IEditorInput>());
get onDidCloseEditor(): Event<IEditorInput> { return this._onDidCloseEditor.event; }
private _onWillCloseEditor: Emitter<IEditorIdentifier> = this._register(new Emitter<IEditorIdentifier>());
get onWillCloseEditor(): Event<IEditorIdentifier> { return this._onWillCloseEditor.event; }
private _onDidCloseEditor: Emitter<IEditorIdentifier> = this._register(new Emitter<IEditorIdentifier>());
get onDidCloseEditor(): Event<IEditorIdentifier> { return this._onDidCloseEditor.event; }
private _onWillOpenEditor: Emitter<IEditorOpeningEvent> = this._register(new Emitter<IEditorOpeningEvent>());
get onWillOpenEditor(): Event<IEditorOpeningEvent> { return this._onWillOpenEditor.event; }
private _onDidOpenEditorFail: Emitter<IEditorInput> = this._register(new Emitter<IEditorInput>());
get onDidOpenEditorFail(): Event<IEditorInput> { return this._onDidOpenEditorFail.event; }
private _onDidOpenEditorFail: Emitter<IEditorIdentifier> = this._register(new Emitter<IEditorIdentifier>());
get onDidOpenEditorFail(): Event<IEditorIdentifier> { return this._onDidOpenEditorFail.event; }
//#endregion
......@@ -109,8 +112,12 @@ export class NextEditorService extends Disposable implements INextEditorService
this._onDidVisibleEditorsChange.fire();
}));
groupDisposeables.push(group.onWillCloseEditor(editor => {
this._onWillCloseEditor.fire({ editor, group: group.id });
}));
groupDisposeables.push(group.onDidCloseEditor(editor => {
this._onDidCloseEditor.fire(editor);
this._onDidCloseEditor.fire({ editor, group: group.id });
}));
groupDisposeables.push(group.onWillOpenEditor(editor => {
......@@ -118,7 +125,7 @@ export class NextEditorService extends Disposable implements INextEditorService
}));
groupDisposeables.push(group.onDidOpenEditorFail(editor => {
this._onDidOpenEditorFail.fire(editor);
this._onDidOpenEditorFail.fire({ editor, group: group.id });
}));
once(group.onWillDispose)(() => {
......
......@@ -7,7 +7,7 @@
import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IEditorInput, IResourceInput, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditor, IEditorOptions } from 'vs/platform/editor/common/editor';
import { GroupIdentifier, IEditorOpeningEvent, IEditorInputWithOptions } from 'vs/workbench/common/editor';
import { GroupIdentifier, IEditorOpeningEvent, IEditorInputWithOptions, IEditorIdentifier } from 'vs/workbench/common/editor';
import { Event } from 'vs/base/common/event';
import { IEditor as ICodeEditor } from 'vs/editor/common/editorCommon';
import { INextEditorGroup } from 'vs/workbench/services/group/common/nextEditorGroupsService';
......@@ -35,10 +35,17 @@ export interface INextEditorService {
*/
readonly onDidVisibleEditorsChange: Event<void>;
/**
* Emitted when an editor is about to get closed. Listeners can
* for example save view state now before the underlying widget
* gets disposed.
*/
readonly onWillCloseEditor: Event<IEditorIdentifier>;
/**
* Emitted when an editor is closed.
*/
readonly onDidCloseEditor: Event<IEditorInput>;
readonly onDidCloseEditor: Event<IEditorIdentifier>;
/**
* Emitted when an editor is about to open. This can be prevented from
......@@ -49,7 +56,7 @@ export interface INextEditorService {
/**
* Emitted when an editor failed to open.
*/
readonly onDidOpenEditorFail: Event<IEditorInput>;
readonly onDidOpenEditorFail: Event<IEditorIdentifier>;
/**
* The currently active editor control if any.
......
......@@ -252,6 +252,14 @@ export interface INextEditorGroup {
*/
readonly onDidActiveEditorChange: Event<void>;
/**
* Emitted when an editor of this group is about to get closed.
*
* Listeners can for example save view state now before the
* underlying widget gets disposed.
*/
readonly onWillCloseEditor: Event<IEditorInput>;
/**
* Emitted when an editor of this group is closed.
*/
......
......@@ -9,8 +9,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import * as errors from 'vs/base/common/errors';
import URI from 'vs/base/common/uri';
import { IEditor } from 'vs/editor/common/editorCommon';
import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput, ITextEditorSelection, Position as GroupPosition } from 'vs/platform/editor/common/editor';
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorGroup, IEditorInputFactoryRegistry, toResource, Extensions as EditorInputExtensions, IFileInputFactory } from 'vs/workbench/common/editor';
import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput, ITextEditorSelection } from 'vs/platform/editor/common/editor';
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorGroup, IEditorInputFactoryRegistry, toResource, Extensions as EditorInputExtensions, IFileInputFactory, IEditorIdentifier } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { FileChangesEvent, IFileService, FileChangeType, FILES_EXCLUDE_CONFIG } from 'vs/platform/files/common/files';
......@@ -85,11 +85,6 @@ interface ISerializedEditorHistoryEntry {
editorInputJSON?: { typeId: string; deserialized: string; };
}
interface IEditorIdentifier {
editor: IEditorInput;
position: GroupPosition;
}
interface IStackEntry {
input: IEditorInput | IResourceInput;
selection?: ITextEditorSelection;
......@@ -180,7 +175,7 @@ export class HistoryService implements IHistoryService {
}
// Remember as last active editor (can be undefined if none opened)
this.lastActiveEditor = activeEditor ? { editor: activeEditor.input, position: activeEditor.group } : void 0;
this.lastActiveEditor = activeEditor ? { editor: activeEditor.input, group: activeEditor.group } : void 0;
// Dispose old listeners
dispose(this.activeEditorListeners);
......@@ -207,7 +202,7 @@ export class HistoryService implements IHistoryService {
return false;
}
if (identifier.position !== editor.group) {
if (identifier.group !== editor.group) {
return false;
}
......
......@@ -1464,38 +1464,38 @@ suite('Editor Stacks Model', () => {
assert.equal(previous, null);
previous = model.previous(true /* jump groups */);
assert.equal(previous.group, group2);
assert.equal(previous.group, group2.id);
assert.equal(previous.editor, input6);
model.setActive(<EditorGroup>previous.group);
(<EditorGroup>previous.group).setActive(<EditorInput>previous.editor);
model.setActive(model.getGroup(previous.group));
model.getGroup(previous.group).setActive(<EditorInput>previous.editor);
let next = model.next(true, false /* jump groups, do NOT cycle at end */);
assert.equal(next, null);
next = model.next(true /* jump groups */);
assert.equal(next.group, group1);
assert.equal(next.group, group1.id);
assert.equal(next.editor, input1);
model.setActive(group1);
group1.setActive(input3);
next = model.next(true /* jump groups */);
assert.equal(next.group, group2);
assert.equal(next.group, group2.id);
assert.equal(next.editor, input4);
model.setActive(<EditorGroup>next.group);
(<EditorGroup>next.group).setActive(<EditorInput>next.editor);
model.setActive(model.getGroup(next.group));
model.getGroup(next.group).setActive(<EditorInput>next.editor);
previous = model.previous(true /* jump groups */);
assert.equal(previous.group, group1);
assert.equal(previous.group, group1.id);
assert.equal(previous.editor, input3);
model.setActive(<EditorGroup>previous.group);
(<EditorGroup>next.group).setActive(<EditorInput>previous.editor);
model.setActive(model.getGroup(previous.group));
model.getGroup(next.group).setActive(<EditorInput>previous.editor);
const last = model.last();
assert.equal(last.group, group1);
assert.equal(last.group, group1.id);
assert.equal(last.editor, input3);
});
......@@ -1528,31 +1528,31 @@ suite('Editor Stacks Model', () => {
assert.equal(previous, null);
previous = model.previous(false /* do NOT jump groups */);
assert.equal(previous.group, group1);
assert.equal(previous.group, group1.id);
assert.equal(previous.editor, input3);
model.setActive(<EditorGroup>previous.group);
(<EditorGroup>previous.group).setActive(<EditorInput>previous.editor);
model.setActive(model.getGroup(previous.group));
(model.getGroup(previous.group)).setActive(<EditorInput>previous.editor);
let next = model.next(false, false /* do NOT jump groups, do NOT cycle at end */);
assert.equal(next, null);
next = model.next(false /* do NOT jump groups */);
assert.equal(next.group, group1);
assert.equal(next.group, group1.id);
assert.equal(next.editor, input1);
model.setActive(group1);
group1.setActive(input3);
next = model.next(false /* do NOT jump groups */);
assert.equal(next.group, group1);
assert.equal(next.group, group1.id);
assert.equal(next.editor, input1);
model.setActive(<EditorGroup>next.group);
(<EditorGroup>next.group).setActive(<EditorInput>next.editor);
model.setActive(model.getGroup(next.group));
(model.getGroup(next.group)).setActive(<EditorInput>next.editor);
previous = model.previous(false /* do NOT jump groups */);
assert.equal(previous.group, group1);
assert.equal(previous.group, group1.id);
assert.equal(previous.editor, input3);
});
......@@ -1699,7 +1699,7 @@ suite('Editor Stacks Model', () => {
assert.equal(events.editorWillClose.length, 1);
assert.equal(events.editorWillClose[0].editor, input3);
assert.equal(events.editorWillClose[0].group, group1);
assert.equal(events.editorWillClose[0].group, group1.id);
assert.equal(input3.isDisposed(), true);
......@@ -1714,7 +1714,7 @@ suite('Editor Stacks Model', () => {
assert.equal(events.editorWillClose.length, 2);
assert.equal(events.editorWillClose[1].editor, input2);
assert.equal(events.editorWillClose[1].group, group1);
assert.equal(events.editorWillClose[1].group, group1.id);
assert.equal(input2.isDisposed(), false);
......@@ -1725,7 +1725,7 @@ suite('Editor Stacks Model', () => {
assert.equal(events.editorWillClose.length, 3);
assert.equal(events.editorWillClose[2].editor, input2);
assert.equal(events.editorWillClose[2].group, group2);
assert.equal(events.editorWillClose[2].group, group2.id);
assert.equal(input2.isDisposed(), true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册