From 64e290b57fa17e7472437478a540c678df581c66 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Thu, 9 Mar 2017 23:01:50 -0800 Subject: [PATCH] Make open() location aware --- src/workspace.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/workspace.js b/src/workspace.js index 4f2e1c9be..064a54210 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -745,14 +745,32 @@ module.exports = class Workspace extends Model { } openItem (item, options = {}) { - let {pane} = options - const {split} = options + let {pane, split} = options if (item == null) return undefined if (pane != null && pane.isDestroyed()) return item if (pane == null) { - pane = this.getActivePane() + // If this is a new item, we want to determine where to put it in the following way: + // - If you provided a split, you want to put it in that split of the center location + // (legacy behavior) + // - If the item specifies a default location, use that. + let locationInfo, location + if (split == null) { + if (locationInfo == null && typeof item.getDefaultLocation === 'function') { + locationInfo = item.getDefaultLocation() + } + if (locationInfo != null) { + if (typeof locationInfo === 'string') { + location = locationInfo + } else { + location = locationInfo.location + split = locationInfo.split + } + } + } + + pane = this.docks[location] == null ? this.getActivePane() : this.docks[location].getActivePane() switch (split) { case 'left': pane = pane.findLeftmostSibling()