         delete tabs[key] for key, value of tabs when value.sessionKey is editor.sessionKey
         @workspaceRef.set "tabs": tabs
 
+      @openedFiles.splice @openedFiles.indexOf(file.path), 1
+
     if file
       @workspaceRef.child("tabs").push
         path       : file.path
         sessionKey : editor.sessionKey
+
+      @openedFiles.push file.path
 
   recoverOldSessionTabs: ->
     @workspaceRef.once "value", (snapshot) =>

      tabHandleContainer : @tabHandleContainer

  createEditorInstance: (file, content, sessionKey) ->
    pane   = new KDTabPaneView
      name : file?.name or "untitled.js"


    @sessionKey       = @getOptions().sessionKey or @createSessionKey()
    @workspaceRef     = @workspace.firepadRef.child @sessionKey
    @isJoinedASession = @getOptions().sessionKey
    @openedFiles      = []

    log "joined an old session again, creating new tabbed editor"

