mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Add Workspace::onDidDestroyPane
This helps with the background-tips conversion
This commit is contained in:
parent
1eab423a1c
commit
fbc9c05096
@ -161,6 +161,21 @@ describe "PaneContainer", ->
|
||||
|
||||
expect(events).toEqual [{pane: pane2}, {pane: pane3}]
|
||||
|
||||
describe "::onDidDestroyPane(callback)", ->
|
||||
it "invokes the given callback when panes are destroyed", ->
|
||||
container = new PaneContainer
|
||||
events = []
|
||||
container.onDidDestroyPane (event) -> events.push(event)
|
||||
|
||||
pane1 = container.getActivePane()
|
||||
pane2 = pane1.splitRight()
|
||||
pane3 = pane2.splitDown()
|
||||
|
||||
pane2.destroy()
|
||||
pane3.destroy()
|
||||
|
||||
expect(events).toEqual [{pane: pane2}, {pane: pane3}]
|
||||
|
||||
describe "::onWillDestroyPaneItem() and ::onDidDestroyPaneItem", ->
|
||||
it "invokes the given callbacks when an item will be destroyed on any pane", ->
|
||||
container = new PaneContainer
|
||||
|
@ -79,6 +79,9 @@ class PaneContainer extends Model
|
||||
fn(pane) for pane in @getPanes()
|
||||
@onDidAddPane ({pane}) -> fn(pane)
|
||||
|
||||
onDidDestroyPane: (fn) ->
|
||||
@emitter.on 'did-destroy-pane', fn
|
||||
|
||||
onDidChangeActivePane: (fn) ->
|
||||
@emitter.on 'did-change-active-pane', fn
|
||||
|
||||
@ -193,6 +196,9 @@ class PaneContainer extends Model
|
||||
didAddPane: (event) ->
|
||||
@emitter.emit 'did-add-pane', event
|
||||
|
||||
didDestroyPane: (event) ->
|
||||
@emitter.emit 'did-destroy-pane', event
|
||||
|
||||
# Called by Model superclass when destroyed
|
||||
destroyed: ->
|
||||
pane.destroy() for pane in @getPanes()
|
||||
|
@ -534,6 +534,7 @@ class Pane extends Model
|
||||
@emitter.emit 'did-destroy'
|
||||
@emitter.dispose()
|
||||
item.destroy?() for item in @items.slice()
|
||||
@container.didDestroyPane(pane: this)
|
||||
|
||||
###
|
||||
Section: Splitting
|
||||
|
@ -233,6 +233,16 @@ class Workspace extends Model
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidAddPane: (callback) -> @paneContainer.onDidAddPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback when a pane is destroyed in the
|
||||
# workspace.
|
||||
#
|
||||
# * `callback` {Function} to be called panes are destroyed.
|
||||
# * `event` {Object} with the following keys:
|
||||
# * `pane` The destroyed pane.
|
||||
#
|
||||
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
|
||||
onDidDestroyPane: (callback) -> @paneContainer.onDidDestroyPane(callback)
|
||||
|
||||
# Extended: Invoke the given callback with all current and future panes in the
|
||||
# workspace.
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user