diff --git a/src/pane-container.js b/src/pane-container.js index c4cb033a8..54cc4477d 100644 --- a/src/pane-container.js +++ b/src/pane-container.js @@ -214,9 +214,7 @@ class PaneContainer { moveActiveItemToPane (destPane) { const item = this.activePane.getActiveItem() - if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) { - return - } + if (!destPane.isItemAllowed(item)) { return } this.activePane.moveItemToPane(item, destPane) destPane.setActiveItem(item) @@ -225,9 +223,7 @@ class PaneContainer { copyActiveItemToPane (destPane) { const item = this.activePane.copyActiveItem() - if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) { - return - } + if (!destPane.isItemAllowed(item)) { return } destPane.activateItem(item) } diff --git a/src/pane.coffee b/src/pane.coffee index 31ee92f77..6713dbf2d 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -91,6 +91,17 @@ class Pane @container = container container.didAddPane({pane: this}) + # Private: Determine whether the given item is allowed to exist in this pane. + # + # * `item` the Item + # + # Returns a {Boolean}. + isItemAllowed: (item) -> + if (typeof item.getAllowedLocations isnt 'function') + true + else + item.getAllowedLocations().includes(@getContainer().getLocation()) + setFlexScale: (@flexScale) -> @emitter.emit 'did-change-flex-scale', @flexScale @flexScale