diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 261ba087d..d6e948d41 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -311,25 +311,35 @@ describe "RootView", -> expect(rootView.panes.children('.pane').length).toBe 1 expect(pane1.outerWidth()).toBe rootView.panes.width() - describe ".activateExtension(extension)", -> + describe "extensions", -> extension = null + beforeEach -> extension = name: 'extension' + deactivate: -> activate: jasmine.createSpy("activate") serialize: -> "it worked" - it "calls activate on the extension", -> - rootView.activateExtension(extension) - expect(extension.activate).toHaveBeenCalledWith(rootView, undefined) + describe "activation", -> + it "calls activate on the extension", -> + rootView.activateExtension(extension) + expect(extension.activate).toHaveBeenCalledWith(rootView, undefined) - it "calls activate on the extension with its previous state", -> - rootView.activateExtension(extension) - extension.activate.reset() + it "calls activate on the extension with its previous state", -> + rootView.activateExtension(extension) + extension.activate.reset() - newRootView = RootView.deserialize(rootView.serialize()) - newRootView.activateExtension(extension) - expect(extension.activate).toHaveBeenCalledWith(newRootView, "it worked") + newRootView = RootView.deserialize(rootView.serialize()) + newRootView.activateExtension(extension) + expect(extension.activate).toHaveBeenCalledWith(newRootView, "it worked") + + describe "deactivation", -> + it "is deactivated when the rootView is deactivated", -> + rootView.activateExtension(extension) + spyOn(extension, "deactivate").andCallThrough() + rootView.deactivate() + expect(extension.deactivate).toHaveBeenCalled() describe "the file finder", -> describe "when the toggle-file-finder event is triggered", -> diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 73f856f06..754e22903 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -88,6 +88,11 @@ class RootView extends View @extensions[extension.name] = extension extension.activate(this, @extensionStates[extension.name]) + deactivate: -> + atom.rootViewStates[$windowNumber] = @serialize() + extension.deactivate() for name, extension of @extensions + @remove() + open: (path) -> buffer = @project.open(path) diff --git a/src/app/window.coffee b/src/app/window.coffee index fab7f746c..dd2b85fc7 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -31,8 +31,7 @@ windowAdditions = atom.windowOpened this shutdown: -> - @saveRootViewState() - @rootView.remove() + @rootView.deactivate() $(window).unbind('focus') $(window).unbind('blur') $(window).off('before') @@ -46,9 +45,6 @@ windowAdditions = new RootView {pathToOpen} $(@rootViewParentSelector).append @rootView - saveRootViewState: -> - atom.rootViewStates[$windowNumber] = @rootView.serialize() - loadUserConfiguration: -> try require atom.userConfigurationPath if fs.exists(atom.userConfigurationPath)