           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
 

    workspaceRefData =
      sessionKey : editor.sessionKey

    if file
      workspaceRefData.path = file.path
      @openedFiles.push file.path

    @tabsRef.push workspaceRefData  unless sessionKey


      @activeTabIndex = newIndex

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

    pane   = new KDTabPaneView
      name : file.name
