Only open paths that are files that exist

The filesystem may have changed while the fuzzy finder
is open or since the last time the paths were loaded so
don't try to open paths unless they are files that
currently exist when confirmed.
This commit is contained in:
Kevin Sawicki
2013-01-11 09:11:03 -08:00
parent 7939b52da0
commit 572b258547
2 changed files with 18 additions and 2 deletions

View File

@@ -86,6 +86,18 @@ describe 'FuzzyFinder', ->
expect(editor2.getPath()).toBe expectedPath
expect(editor2.isFocused).toBeTruthy()
describe "when the selected path isn't a file that exists", ->
it "leaves the the tree view open, doesn't open the path in the editor, and displays an error", ->
rootView.attachToDom()
path = rootView.getActiveEditor().getPath()
rootView.trigger 'fuzzy-finder:toggle-file-finder'
finder.confirmed('dir/this/is/not/a/file.txt')
expect(finder.hasParent()).toBeTruthy()
expect(rootView.getActiveEditor().getPath()).toBe path
expect(finder.find('.error').text().length).toBeGreaterThan 0
advanceClock(2000)
expect(finder.find('.error').text().length).toBe 0
describe "buffer-finder behavior", ->
describe "toggling", ->
describe "when the active editor contains edit sessions for buffers with paths", ->

View File

@@ -65,8 +65,12 @@ class FuzzyFinder extends SelectList
confirmed : (path) ->
return unless path.length
@cancel()
@openPath(path)
if fs.isFile(rootView.project.resolve(path))
@cancel()
@openPath(path)
else
@setError('Selected path does not exist')
setTimeout(=> @setError('')), 2000
cancelled: ->
@miniEditor.setText('')