From a6424a795eb3a7aa97971c2ef18ed096f0165989 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Thu, 9 Mar 2017 17:13:39 -0800 Subject: [PATCH] Separate searching panes from creation --- src/workspace.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/workspace.js b/src/workspace.js index 33fec9d67..ff8b0d593 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -587,13 +587,13 @@ module.exports = class Workspace extends Model { pane = this.getActivePane().findLeftmostSibling() break case 'right': - pane = this.getActivePane().findOrCreateRightmostSibling() + pane = this.getActivePane().findRightmostSibling() break case 'up': pane = this.getActivePane().findTopmostSibling() break case 'down': - pane = this.getActivePane().findOrCreateBottommostSibling() + pane = this.getActivePane().findBottommostSibling() break default: pane = this.getActivePane() @@ -602,11 +602,12 @@ module.exports = class Workspace extends Model { } let item - if (uri != null) { + if (uri != null && pane != null) { item = pane.itemForURI(uri) } if (item == null) { item = this.createItemForURI(uri, options) + pane = null } return Promise.resolve(item) @@ -712,10 +713,29 @@ module.exports = class Workspace extends Model { } openItem (item, options = {}) { - const {pane} = options + let {pane} = options + const {split} = options if (item == null) return undefined - if (pane.isDestroyed()) return item + if (pane != null && pane.isDestroyed()) return item + + if (pane == null) { + pane = this.getActivePane() + switch (split) { + case 'left': + pane = pane.findLeftmostSibling() + break + case 'right': + pane = pane.findOrCreateRightmostSibling() + break + case 'up': + pane = pane.findTopmostSibling() + break + case 'down': + pane = pane.findOrCreateBottommostSibling() + break + } + } if (!options.pending && (pane.getPendingItem() === item)) { pane.clearPendingItem()