mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
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:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user