diff --git a/src/vs/workbench/common/editor/editorStacksModel.ts b/src/vs/workbench/common/editor/editorStacksModel.ts index 532eebcfe1bedead0746dcbaf3a25b2ed7a3da8e..7c9a22e5775ab2482e9695349da79c6c4f52f9b4 100644 --- a/src/vs/workbench/common/editor/editorStacksModel.ts +++ b/src/vs/workbench/common/editor/editorStacksModel.ts @@ -151,8 +151,6 @@ export class EditorGroup implements IEditorGroup { public openEditor(editor: EditorInput, options?: IEditorOpenOptions): void { const index = this.indexOf(editor); - const indexOfActive = this.indexOf(this.active); - const indexOfPreview = this.indexOf(this.preview); const makeActive = (options && options.active) || !this.activeEditor; const makePinned = options && options.pinned; @@ -162,6 +160,7 @@ export class EditorGroup implements IEditorGroup { // Insert into our list of editors if pinned or we are first if (makePinned || !this.preview) { + const indexOfActive = this.indexOf(this.active); // Insert to the RIGHT of active editor if (DEFAULT_OPEN_EDITOR_DIRECTION === Direction.RIGHT) { @@ -180,6 +179,8 @@ export class EditorGroup implements IEditorGroup { // Handle preview if (!makePinned) { + const indexOfPreview = this.indexOf(this.preview); + this.closeEditor(this.preview); this.preview = editor; this.splice(indexOfPreview, true, editor); @@ -303,7 +304,7 @@ export class EditorGroup implements IEditorGroup { private splice(index: number, del: boolean, editor?: EditorInput): void { // Perform on editors array - const args:any[] = [index, del ? 1 : 0]; + const args: any[] = [index, del ? 1 : 0]; if (editor) { args.push(editor); }