 
           describe "when a file or directory already exists at the target path", ->
             it "shows an error message and does not close the dialog", ->
+              fs.writeFileSync(path.join(rootDirPath, 'target.txt'), '')
+              newPath = path.join(rootDirPath, 'target.txt')
+              moveDialog.miniEditor.setText(newPath)
+
+              atom.commands.dispatch moveDialog.element, 'core:confirm'
+
+              expect(moveDialog.errorMessage.textContent).toContain 'already exists'
+              expect(moveDialog.element).toHaveClass('error')
+              expect(moveDialog.element.parentElement).toBeTruthy()
+              expect(callback).not.toHaveBeenCalled()
+
+          describe 'when the file is currently open', ->
+            beforeEach ->
+              waitForWorkspaceOpenEvent ->
+                atom.workspace.open(filePath)
+
+            it 'has its path updated', ->
+              newPath = path.join(rootDirPath, 'renamed-test-file.txt')
+              moveDialog.miniEditor.setText(path.basename(newPath))
+
+              atom.commands.dispatch moveDialog.element, 'core:confirm'
+
+              expect(atom.workspace.getActiveTextEditor().getPath()).toBe newPath
+
+            it 'does not update paths for similarly-named editors', ->
+              filePath2 = path.join(dirPath, 'test-file.txt2')
+              fs.writeFileSync(filePath2, 'copy')
+
+              waitForWorkspaceOpenEvent ->
+                atom.workspace.open(filePath2)
+
               runs ->
-                fs.writeFileSync(path.join(rootDirPath, 'target.txt'), '')
-                newPath = path.join(rootDirPath, 'target.txt')
-                moveDialog.miniEditor.setText(newPath)
+                newPath = path.join(rootDirPath, 'renamed-test-file.txt')
+                moveDialog.miniEditor.setText(path.basename(newPath))
 
                 atom.commands.dispatch moveDialog.element, 'core:confirm'
 
-                expect(moveDialog.errorMessage.textContent).toContain 'already exists'
-                expect(moveDialog.element).toHaveClass('error')
-                expect(moveDialog.element.parentElement).toBeTruthy()
-                expect(callback).not.toHaveBeenCalled()
+                editors = atom.workspace.getTextEditors()
+                expect(editors[0].getPath()).toBe newPath
+                expect(editors[1].getPath()).toBe filePath2
 
         describe "when 'core:cancel' is triggered on the move dialog", ->
           it "removes the dialog and focuses the tree view", ->


        gammaDir = findDirectoryContainingText(treeView.roots[0], 'gamma')
        gammaDir.expand()
        deltaFile = gammaDir.entries.children[2]

        [dragStartEvent, dragEnterEvent, dropEvent] =
            eventHelpers.buildInternalDragEvents(deltaFile, alphaDir.querySelector('.header'), alphaDir)

        runs ->
          treeView.onDragStart(dragStartEvent)
          treeView.onDrop(dropEvent)
          expect(alphaDir.children.length).toBe 2

        waitsFor "directory view contents to refresh", ->
          findDirectoryContainingText(treeView.roots[0], 'alpha').querySelectorAll('.entry').length > 2

        runs ->
          expect(findDirectoryContainingText(treeView.roots[0], 'alpha').querySelectorAll('.entry').length).toBe 3

    describe "when dropping a DirectoryView onto a DirectoryView's header", ->
      it "should move the directory to the hovered directory", ->
        # Dragging thetaDir onto alphaDir
        alphaDir = findDirectoryContainingText(treeView.roots[0], 'alpha')

              atom.commands.dispatch(treeView.element, "tree-view:move")
              moveDialog = atom.workspace.getModalPanels()[0].getItem()

        it "opens a move dialog with the folder's current path populated", ->
          extension = path.extname(dirPath)
          expect(moveDialog.element).toExist()
