From 0c12f712c994aba69e128c272c2b3964fe1e0091 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 12:03:01 -0700 Subject: [PATCH 1/9] Add atom.workspace to every spec We add project to every spec, I'd like to add workspace so that we can move all the opener logic to workspace. --- spec/spec-helper.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 85beeecc5..64d648d6e 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -7,7 +7,7 @@ path = require 'path' _ = require 'underscore-plus' fs = require 'fs-plus' KeymapManager = require '../src/keymap-extensions' -{$, WorkspaceView} = require 'atom' +{$, WorkspaceView, Workspace} = require 'atom' Config = require '../src/config' {Point} = require 'text-buffer' Project = require '../src/project' @@ -49,6 +49,7 @@ if specDirectory beforeEach -> $.fx.off = true projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures') + atom.workspace = new Workspace() atom.project = new Project(path: projectPath) atom.keymaps.keyBindings = _.clone(keyBindingsToRestore) @@ -115,6 +116,9 @@ afterEach -> atom.project?.destroy?() atom.project = null + atom.workspace?.destroy() + atom.workspace = null + delete atom.state.packageStates $('#jasmine-content').empty() unless window.debugContent From 6f2695388c81c9ad19a43035d78329294fcfe10f Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 12:12:56 -0700 Subject: [PATCH 2/9] Add destroy method --- src/workspace.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/workspace.coffee b/src/workspace.coffee index 1350edea6..6d7eadfa3 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -39,6 +39,9 @@ class Workspace extends Model when 'atom://.atom/init-script' @open(atom.getUserInitScriptPath()) + destroy: -> + @unsubscribe() + # Called by the Serializable mixin during deserialization deserializeParams: (params) -> params.paneContainer = PaneContainer.deserialize(params.paneContainer) From 61ae18549435702807757a614ca37ce7dd550d25 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 13:23:50 -0700 Subject: [PATCH 3/9] Create workspace after project --- spec/spec-helper.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 64d648d6e..b16f6bd79 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -49,8 +49,8 @@ if specDirectory beforeEach -> $.fx.off = true projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures') - atom.workspace = new Workspace() atom.project = new Project(path: projectPath) + atom.workspace = new Workspace() atom.keymaps.keyBindings = _.clone(keyBindingsToRestore) window.resetTimeouts() From 4165a69fed74f94e9ac7367864372eccba242cfa Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 14:02:21 -0700 Subject: [PATCH 4/9] Change destroy order --- spec/spec-helper.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index b16f6bd79..628142185 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -111,14 +111,14 @@ afterEach -> atom.workspaceView?.remove?() atom.workspaceView = null + + atom.workspace?.destroy() + atom.workspace = null delete atom.state.workspace atom.project?.destroy?() atom.project = null - atom.workspace?.destroy() - atom.workspace = null - delete atom.state.packageStates $('#jasmine-content').empty() unless window.debugContent From f90f48e3f08b1de4486fc70631893b0407e5a66c Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 14:08:00 -0700 Subject: [PATCH 5/9] Use atom.workspace if one exists --- src/workspace-view.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index eb904f119..f51216bcb 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -78,7 +78,8 @@ class WorkspaceView extends View @div class: 'panes', outlet: 'panes' initialize: (@model) -> - @model ?= new Workspace + if not @model? + @model = atom.workspace ? new Workspace panes = new PaneContainerView(@model.paneContainer) @panes.replaceWith(panes) From 784d22368e0e7236232ead7d8781f40f24b9a3b0 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 14:19:06 -0700 Subject: [PATCH 6/9] Remove unneeded ? --- spec/spec-helper.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 628142185..9174c5e0e 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -116,7 +116,7 @@ afterEach -> atom.workspace = null delete atom.state.workspace - atom.project?.destroy?() + atom.project?.destroy() atom.project = null delete atom.state.packageStates From 662f2529125abf238a12b148bdbfef37b1c68333 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 14:19:27 -0700 Subject: [PATCH 7/9] Workspace is destroyed automatically --- src/workspace.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 6d7eadfa3..1350edea6 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -39,9 +39,6 @@ class Workspace extends Model when 'atom://.atom/init-script' @open(atom.getUserInitScriptPath()) - destroy: -> - @unsubscribe() - # Called by the Serializable mixin during deserialization deserializeParams: (params) -> params.paneContainer = PaneContainer.deserialize(params.paneContainer) From d47cc6fa0bcfa7ca6f1ff14e805392a31bec0da5 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 14:36:32 -0700 Subject: [PATCH 8/9] Remove explicit atom.workspace.destroy call --- spec/spec-helper.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 9174c5e0e..5574abae5 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -111,9 +111,6 @@ afterEach -> atom.workspaceView?.remove?() atom.workspaceView = null - - atom.workspace?.destroy() - atom.workspace = null delete atom.state.workspace atom.project?.destroy() From 606160d312c38235f091027907886bed0868c331 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 2 Apr 2014 16:04:14 -0700 Subject: [PATCH 9/9] Use unless --- src/workspace-view.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index f51216bcb..dc43aed60 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -78,8 +78,7 @@ class WorkspaceView extends View @div class: 'panes', outlet: 'panes' initialize: (@model) -> - if not @model? - @model = atom.workspace ? new Workspace + @model = atom.workspace ? new Workspace unless @model? panes = new PaneContainerView(@model.paneContainer) @panes.replaceWith(panes)