mirror of
https://github.com/atom/atom.git
synced 2026-02-18 18:34:21 -05:00
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:
@@ -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", ->
|
||||
|
||||
@@ -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('')
|
||||
|
||||
Reference in New Issue
Block a user