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

more test and bugfix

上级 461a529b
......@@ -65,7 +65,6 @@ export interface IEditorOpenOptions {
// Open
// To the left / to the right (setting)
// Close
// Reveals from the left / from the right (setting)
// Close Others
// Close Editors to the Right
// Close All
......@@ -160,13 +159,13 @@ export class EditorGroup implements IEditorGroup {
public openEditor(editor: EditorInput, options?: IEditorOpenOptions): void {
const index = this.indexOf(editor);
const makeActive = (options && options.active) || !this.activeEditor || this.matches(this.preview, this.activeEditor);
const makePinned = options && options.pinned;
const makeActive = (options && options.active) || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
// New editor
if (index === -1) {
// Insert into our list of editors if pinned or we are first
// Insert into our list of editors if pinned or we have no preview editor
if (makePinned || !this.preview) {
const indexOfActive = this.indexOf(this.active);
......@@ -187,9 +186,11 @@ export class EditorGroup implements IEditorGroup {
// Handle preview
if (!makePinned) {
// Replace existing preview with this editor if we have a preview
if (this.preview) {
const indexOfPreview = this.indexOf(this.preview);
this.closeEditor(this.preview);
this.closeEditor(this.preview); // TODO this can cause the next in MRU list to become active which may be unwanted
this.splice(indexOfPreview, false, editor);
}
......@@ -264,6 +265,7 @@ export class EditorGroup implements IEditorGroup {
this.active = editor;
// Bring to front in MRU list
this.setMostRecentlyUsed(editor);
// Event
......@@ -379,7 +381,7 @@ export class EditorGroup implements IEditorGroup {
export class EditorStacksModel implements IEditorStacksModel {
private _groups: EditorGroup[];
private active: EditorGroup; // index of group with currently active editor
private active: EditorGroup;
private _onGroupOpened: Emitter<EditorGroup>;
private _onGroupClosed: Emitter<EditorGroup>;
......
......@@ -74,7 +74,7 @@ function input(id = String(index++)): EditorInput {
suite('Editor Stacks Model', () => {
teardown(() => {
teardown(() =>  {
index = 1;
setOpenEditorDirection(Direction.RIGHT);
});
......@@ -490,6 +490,38 @@ suite('Editor Stacks Model', () => {
assert.equal(group.count, 0);
});
test('Stack - Multiple Editors - Pinned & Non Active', function () {
const model = create();
const group = model.openGroup('group');
const input1 = input();
group.openEditor(input1);
assert.equal(group.activeEditor, input1);
assert.equal(group.previewEditor, input1);
assert.equal(group.getEditors()[0], input1);
assert.equal(group.count, 1);
const input2 = input();
group.openEditor(input2, { pinned: true, active: false });
assert.equal(group.activeEditor, input1);
assert.equal(group.previewEditor, input1);
assert.equal(group.getEditors()[0], input1);
assert.equal(group.getEditors()[1], input2);
assert.equal(group.count, 2);
const input3 = input();
group.openEditor(input3, { pinned: true, active: false });
assert.equal(group.activeEditor, input1);
assert.equal(group.previewEditor, input1);
assert.equal(group.getEditors()[0], input1);
assert.equal(group.getEditors()[1], input3);
assert.equal(group.getEditors()[2], input2);
assert.equal(group.isPinned(input1), false);
assert.equal(group.isPinned(input2), true);
assert.equal(group.isPinned(input3), true);
assert.equal(group.count, 3);
});
test('Stack - Multiple Editors - real user example', function () {
const model = create();
......@@ -599,7 +631,4 @@ suite('Editor Stacks Model', () => {
assert.equal(group.activeEditor, null);
assert.equal(group.previewEditor, null);
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册