From f77f62625e52cfdce410aab9b349dccecf3b7ffd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sun, 11 Oct 2015 18:12:11 +0200 Subject: [PATCH] Add `activateItem` config to `Workspace::open` Now that we have deleted `Project::open(...)`, all the methods that previously used it need to switch to `Workspace::open(...)` instead. These two methods, however, are not idempotent because the latter performs additional operations. Since some specs relied on not activating an item after opening it, this commit adds a parameter to prevent such activation. Refs: https://github.com/atom/tabs/commit/1ebcf166c73a9d55932a78b1246dbd5a50077ec5 --- src/workspace.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 6d87fbbf4..743c32e12 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -336,6 +336,8 @@ class Workspace extends Model # item will be opened in the rightmost pane of the current active pane's row. # * `activatePane` A {Boolean} indicating whether to call {Pane::activate} on # containing pane. Defaults to `true`. + # * `activateItem` A {Boolean} indicating whether to call {Pane::activateItem} + # on containing pane. Defaults to `true`. # * `searchAllPanes` A {Boolean}. If `true`, the workspace will attempt to # activate an existing item for the given URI on any pane. # If `false`, only the active pane will be searched for @@ -374,9 +376,12 @@ class Workspace extends Model # initially. Defaults to `0`. # * `activatePane` A {Boolean} indicating whether to call {Pane::activate} on # the containing pane. Defaults to `true`. + # * `activateItem` A {Boolean} indicating whether to call {Pane::activateItem} + # on containing pane. Defaults to `true`. openSync: (uri='', options={}) -> {initialLine, initialColumn} = options activatePane = options.activatePane ? true + activateItem = options.activateItem ? true uri = @project.resolvePath(uri) item = @getActivePane().itemForURI(uri) @@ -384,13 +389,14 @@ class Workspace extends Model item ?= opener(uri, options) for opener in @getOpeners() when not item item ?= @project.openSync(uri, {initialLine, initialColumn}) - @getActivePane().activateItem(item) + @getActivePane().activateItem(item) if activateItem @itemOpened(item) @getActivePane().activate() if activatePane item openURIInPane: (uri, pane, options={}) -> activatePane = options.activatePane ? true + activateItem = options.activateItem ? true if uri? item = pane.itemForURI(uri) @@ -417,7 +423,7 @@ class Workspace extends Model pane = new Pane({items: [item], @config, @confirm}) @paneContainer.root = pane @itemOpened(item) - pane.activateItem(item) + pane.activateItem(item) if activateItem pane.activate() if activatePane initialLine = initialColumn = 0