From 96631016718ad5e7d8375812c00712094fefdb46 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Fri, 31 Mar 2017 14:16:26 -0700 Subject: [PATCH 1/2] Always add opened items to the workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit changes the behavior of `open()` so that the item will be added to the workspace—even if the `activateItem` option is false. This provides a way to open (and add) an item without activating it, but removes the ability to open without adding. For that, we've made the `createItemForURI()` method public 😊 --- spec/workspace-spec.js | 12 ++++++++++++ src/workspace.js | 11 ++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 73eaf162c..5c02b8852 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -281,6 +281,18 @@ describe('Workspace', () => { }) }) + describe("when the 'activateItem' option is false", () => { + it('adds the item to the workspace', () => { + let editor + waitsForPromise(() => workspace.open('a')) + waitsForPromise(() => workspace.open('b', {activateItem: false}).then(o => { editor = o })) + runs(() => { + expect(workspace.getPaneItems()).toContain(editor) + expect(workspace.getActivePaneItem()).not.toBe(editor) + }) + }) + }) + describe('when the active pane does not have an editor for the given uri', () => { it('adds and activates a new editor for the given path on the active pane', () => { let editor = null diff --git a/src/workspace.js b/src/workspace.js index 7e7ddbe30..894d67b62 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -719,7 +719,9 @@ module.exports = class Workspace extends Model { this.itemOpened(item) - if (options.activateItem !== false) { + if (options.activateItem === false) { + pane.addItem(item, {pending: options.pending}) + } else { pane.activateItem(item, {pending: options.pending}) } @@ -841,6 +843,13 @@ module.exports = class Workspace extends Model { return this.open(uri, {pane}) } + // Public: Creates a new item that corresponds to the provided URI. + // + // If no URI is given, or no registered opener can open the URI, a new empty + // {TextEditor} will be created. + // + // * `uri` A {String} containing a URI. + // // Returns a {Promise} that resolves to the {TextEditor} (or other item) for the given URI. createItemForURI (uri, options) { if (uri != null) { From 95be4c5c99109e73167e683b3ed5864f3e0afdbf Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 3 Apr 2017 13:36:52 -0600 Subject: [PATCH 2/2] Upgrade bundled packages to not rely on activateItem: false Signed-off-by: Max Brunsfeld --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 15a604dda..f1617a088 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "autocomplete-plus": "2.35.0", "autocomplete-snippets": "1.11.0", "autoflow": "0.29.0", - "autosave": "0.24.1", + "autosave": "0.24.2", "background-tips": "0.27.0", "bookmarks": "0.44.3", "bracket-matcher": "0.85.5", @@ -103,7 +103,7 @@ "dev-live-reload": "0.47.1", "encoding-selector": "0.23.3", "exception-reporting": "0.41.3", - "find-and-replace": "0.207.3", + "find-and-replace": "0.207.4", "fuzzy-finder": "1.5.4", "git-diff": "1.3.5", "go-to-line": "0.32.0", @@ -124,7 +124,7 @@ "status-bar": "1.8.5", "styleguide": "0.49.6", "symbols-view": "0.115.5", - "tabs": "0.105.0", + "tabs": "0.105.1", "timecop": "0.36.0", "tree-view": "0.216.0", "update-package-dependencies": "0.11.0",