Allow non-existent files to be opened from fuzzy finder

The previous isFileSync check prevented unsaved buffers with a path to a
non-existent file from being opened from the fuzzy finder.

Now an error is only displayed if the selected path is a directory.

Closes #686
This commit is contained in:
Kevin Sawicki
2013-08-09 10:29:28 -07:00
parent 82882624ce
commit 136836e615
2 changed files with 6 additions and 6 deletions

View File

@@ -98,13 +98,13 @@ class FuzzyFinderView extends SelectList
confirmed : ({filePath}) ->
return unless filePath
if fsUtils.isFileSync(filePath)
if fsUtils.isDirectorySync(filePath)
@setError('Selected path is a directory')
setTimeout((=> @setError()), 2000)
else
lineNumber = @getLineNumber()
@cancel()
@openPath(filePath, lineNumber)
else
@setError('Selected path does not exist')
setTimeout((=> @setError()), 2000)
toggleFileFinder: ->
@finderMode = 'file'

View File

@@ -109,12 +109,12 @@ describe 'FuzzyFinder', ->
expect(editor2.getPath()).toBe expectedPath
expect(editor2.isFocused).toBeTruthy()
describe "when the selected path isn't a file that exists", ->
describe "when the selected path is a directory", ->
it "leaves the the tree view open, doesn't open the path in the editor, and displays an error", ->
rootView.attachToDom()
editorPath = rootView.getActiveView().getPath()
rootView.trigger 'fuzzy-finder:toggle-file-finder'
finderView.confirmed({filePath: 'dir/this/is/not/a/file.txt'})
finderView.confirmed({filePath: project.resolve('dir')})
expect(finderView.hasParent()).toBeTruthy()
expect(rootView.getActiveView().getPath()).toBe editorPath
expect(finderView.error.text().length).toBeGreaterThan 0