From 48336fb95eb57ff1af79af06c2fdcd0385644abd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 7 Apr 2017 15:30:44 -0700 Subject: [PATCH] Don't use workspace's itemLocationStore in tests --- spec/workspace-spec.js | 9 +++++++++ src/atom-environment.coffee | 2 +- src/workspace.js | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index f888b9163..58c5b0b43 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -294,6 +294,15 @@ describe('Workspace', () => { }) describe('when the active pane does not have an editor for the given uri', () => { + beforeEach(() => { + atom.workspace.enablePersistence = true + }) + + afterEach(async () => { + await atom.workspace.itemLocationStore.clear() + atom.workspace.enablePersistence = false + }) + it('adds and activates a new editor for the given path on the active pane', () => { let editor = null waitsForPromise(() => workspace.open('a').then(o => { editor = o })) diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index dc5c4519a..42c98dae5 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -173,7 +173,7 @@ class AtomEnvironment extends Model @workspace = new Workspace({ @config, @project, packageManager: @packages, grammarRegistry: @grammars, deserializerManager: @deserializers, notificationManager: @notifications, @applicationDelegate, viewRegistry: @views, assert: @assert.bind(this), - textEditorRegistry: @textEditors, styleManager: @styles + textEditorRegistry: @textEditors, styleManager: @styles, @enablePersistence }) @themes.workspace = @workspace diff --git a/src/workspace.js b/src/workspace.js index 131d28ca7..69d18bd12 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -42,6 +42,7 @@ module.exports = class Workspace extends Model { this.didActivatePaneContainer = this.didActivatePaneContainer.bind(this) this.didHideDock = this.didHideDock.bind(this) + this.enablePersistence = params.enablePersistence this.packageManager = params.packageManager this.config = params.config this.project = params.project @@ -359,9 +360,9 @@ module.exports = class Workspace extends Model { for (const paneContainer of this.getPaneContainers()) { paneContainer.observePanes(pane => { pane.onDidAddItem(({item}) => { - if (typeof item.getURI === 'function') { + if (typeof item.getURI === 'function' && this.enablePersistence) { const uri = item.getURI() - if (uri != null) { + if (uri) { const location = paneContainer.getLocation() let defaultLocation if (typeof item.getDefaultLocation === 'function') { @@ -782,7 +783,7 @@ module.exports = class Workspace extends Model { pane = options.pane } else { let location = options.location - if (!location && !options.split && uri) { + if (!location && !options.split && uri && this.enablePersistence) { location = await this.itemLocationStore.load(uri) } if (!location && typeof item.getDefaultLocation === 'function') {