mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
RootView deactivates extensions when it is deactivated
This commit is contained in:
parent
f3c89240a3
commit
670717ca3b
@ -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", ->
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user