Fall back to first pane if activePaneId is invalid

When deserializing PaneContainer.

Fixes #4069

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Nathan Sobo 2014-11-07 15:44:59 -07:00 committed by Max Brunsfeld
parent 330988ad16
commit 6934b83acc
2 changed files with 9 additions and 0 deletions

View File

@ -33,6 +33,13 @@ describe "PaneContainer", ->
[pane1B, pane2B, pane3B] = containerB.getPanes()
expect(containerB.getActivePane()).toBe pane3B
it "makes the first pane active if no pane exists for the activePaneId", ->
pane3A.activate()
state = containerA.serialize()
state.activePaneId = -22
containerB = atom.deserializers.deserialize(state)
expect(containerB.getActivePane()).toBe containerB.getPanes()[0]
it "does not allow the root pane to be destroyed", ->
container = new PaneContainer
container.getRoot().destroy()

View File

@ -40,6 +40,8 @@ class PaneContainer extends Model
@registerViewProviders()
@setRoot(params?.root ? new Pane)
@setActivePane(@getPanes()[0]) unless @getActivePane()
@destroyEmptyPanes() if params?.destroyEmptyPanes
@monitorActivePaneItem()