From f62cb5d4276a167a09e1ac4d3655f191cfbd0b41 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Thu, 8 Jun 2017 15:39:59 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20attempt=20to=20copy=20it?= =?UTF-8?q?ems=20that=20aren't=20copyable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/workspace-element-spec.js | 15 +++++++++++++++ src/pane-container.js | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js index d3027e574..48ed09cee 100644 --- a/spec/workspace-element-spec.js +++ b/spec/workspace-element-spec.js @@ -499,6 +499,21 @@ describe('WorkspaceElement', () => { expect(workspace.paneForItem(item)).toBe(startingPane) }) }) + + describe("when the item doesn't implement a `copy` function", () => { + it('does not copy the active item', function () { + const item = document.createElement('div') + const paneBelow = startingPane.splitDown() + expect(paneBelow.getItems().length).toEqual(0) + + startingPane.activate() + startingPane.activateItem(item) + workspaceElement.focusPaneViewAbove() + workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: true}) + expect(workspace.paneForItem(item)).toBe(startingPane) + expect(paneBelow.getItems().length).toEqual(0) + }) + }) }) }) diff --git a/src/pane-container.js b/src/pane-container.js index 54cc4477d..c914cc37f 100644 --- a/src/pane-container.js +++ b/src/pane-container.js @@ -223,9 +223,9 @@ class PaneContainer { copyActiveItemToPane (destPane) { const item = this.activePane.copyActiveItem() - if (!destPane.isItemAllowed(item)) { return } - - destPane.activateItem(item) + if (item && destPane.isItemAllowed(item)) { + destPane.activateItem(item) + } } destroyEmptyPanes () {