mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
@@ -6,10 +6,16 @@ describe "PaneContainerModel", ->
|
||||
[containerA, pane1A, pane2A, pane3A] = []
|
||||
|
||||
beforeEach ->
|
||||
pane1A = new PaneModel
|
||||
# This is a dummy item to prevent panes from being empty on deserialization
|
||||
class Item
|
||||
atom.deserializers.add(this)
|
||||
@deserialize: -> new this
|
||||
serialize: -> deserializer: 'Item'
|
||||
|
||||
pane1A = new PaneModel(items: [new Item])
|
||||
containerA = new PaneContainerModel(root: pane1A)
|
||||
pane2A = pane1A.splitRight()
|
||||
pane3A = pane2A.splitDown()
|
||||
pane2A = pane1A.splitRight(items: [new Item])
|
||||
pane3A = pane2A.splitDown(items: [new Item])
|
||||
|
||||
it "preserves the focused pane across serialization", ->
|
||||
expect(pane3A.focused).toBe true
|
||||
|
||||
@@ -130,7 +130,7 @@ describe "PaneContainer", ->
|
||||
expect(newContainer.find('.pane-row > :contains(1)').width()).toBe 150
|
||||
expect(newContainer.find('.pane-row > .pane-column > :contains(2)').height()).toBe 100
|
||||
|
||||
xit "removes empty panes on deserialization", ->
|
||||
it "removes empty panes on deserialization", ->
|
||||
# only deserialize pane 1's view successfully
|
||||
TestView.deserialize = ({name}) -> new TestView(name) if name is '1'
|
||||
newContainer = atom.deserializers.deserialize(container.serialize())
|
||||
|
||||
@@ -16,12 +16,14 @@ class PaneContainerModel extends Model
|
||||
@behavior 'activePaneItem', ->
|
||||
@$activePane.switch (activePane) -> activePane?.$activeItem
|
||||
|
||||
constructor: ->
|
||||
constructor: (params) ->
|
||||
super
|
||||
@subscribe @$root, @onRootChanged
|
||||
@destroyEmptyPanes() if params?.destroyEmptyPanes
|
||||
|
||||
deserializeParams: (params) ->
|
||||
params.root = atom.deserializers.deserialize(params.root, container: this)
|
||||
params.destroyEmptyPanes = true
|
||||
params
|
||||
|
||||
serializeParams: (params) ->
|
||||
@@ -59,3 +61,6 @@ class PaneContainerModel extends Model
|
||||
@subscribe root, 'destroyed', =>
|
||||
@activePane = null
|
||||
@root = null
|
||||
|
||||
destroyEmptyPanes: ->
|
||||
pane.destroy() for pane in @getPanes() when pane.items.length is 0
|
||||
|
||||
@@ -110,10 +110,6 @@ class PaneContainer extends View
|
||||
return pane if view?
|
||||
null
|
||||
|
||||
removeEmptyPanes: ->
|
||||
for pane in @getPanes() when pane.getItems().length == 0
|
||||
pane.remove()
|
||||
|
||||
focusNextPane: ->
|
||||
panes = @getPanes()
|
||||
if panes.length > 1
|
||||
|
||||
@@ -53,7 +53,7 @@ class PaneModel extends Model
|
||||
# Private: Called by the Serializable mixin during deserialization.
|
||||
deserializeParams: (params) ->
|
||||
{items, activeItemUri} = params
|
||||
params.items = items.map (itemState) -> atom.deserializers.deserialize(itemState)
|
||||
params.items = compact(items.map (itemState) -> atom.deserializers.deserialize(itemState))
|
||||
params.activeItem = find params.items, (item) -> item.getUri?() is activeItemUri
|
||||
params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user