     @workspaceRef.child("tabs").push workspaceRefData  unless sessionKey
 
     pane.on "KDTabPaneDestroy", =>
+      removedPaneIndex = @tabView.getPaneIndex pane
+      @editors.splice removedPaneIndex, 1
       @workspaceRef.once "value", (snapshot) =>
         {tabs} = snapshot.val()
         return unless tabs

    }

    pane.addSubView editor
    @tabView.addPane pane
    @activeTabIndex = @tabView.panes.length



    @workspaceRef.onDisconnect().remove()  if @workspace.amIHost()

  getActivePaneEditor: ->
    return @editors[@getActivePaneIndex()] or null

  getActivePaneContent: ->
    return @getActivePaneEditor().getValue()

  getActivePaneFileData: ->
    return @getActivePaneEditor().getData()

  getActivePane: ->
    return @tabView.getActivePane()

  getActivePaneIndex: ->
    return @tabView.getPaneIndex @getActivePane()

  createEditorTabs: ->
    @tabHandleContainer = new ApplicationTabHandleHolder
