           delete tabs[key]
         @workspaceRef.set { tabs }
 
-      @openedFiles.splice @openedFiles.indexOf(file.path), 1
+      @openedFiles.splice @openedFiles.indexOf(plainPath), 1
 
     return yes # return something instead of workspaceRef.child
 

      @activeTabIndex = newIndex

  createEditorInstance: (file, content, sessionKey) ->
    if file
      fileIndexInOpenedFiles = @openedFiles.indexOf(file.path)
      if fileIndexInOpenedFiles > -1
        return  @tabView.showPaneByIndex fileIndexInOpenedFiles
    else
      file = FSHelper.createFileFromPath "localfile:/untitled.txt"

    pane   = new KDTabPaneView
      name : file.name

    workspaceRefData =
      sessionKey : editor.sessionKey

    workspaceRefData.path = plainPath
    @openedFiles.push plainPath

    @tabsRef.push workspaceRefData  unless sessionKey

