mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Display error if no files match word under cursor
This commit is contained in:
@@ -304,6 +304,31 @@ describe 'FuzzyFinder', ->
|
||||
expect(finder).not.toBeVisible()
|
||||
expect(openedPath).toBe "sample.txt"
|
||||
|
||||
it "displays error when the word under the cursor doesn't match any files", ->
|
||||
editor.setText("moogoogaipan")
|
||||
editor.setCursorBufferPosition([0,5])
|
||||
|
||||
rootView.trigger 'fuzzy-finder:find-under-cursor'
|
||||
|
||||
waitsFor ->
|
||||
finder.is(':visible')
|
||||
|
||||
runs ->
|
||||
expect(finder.find('.error').text().length).toBeGreaterThan 0
|
||||
|
||||
it "displays error when there is no word under the cursor", ->
|
||||
editor.setText("&&&&&&&&&&&&&&& sample")
|
||||
editor.setCursorBufferPosition([0,5])
|
||||
|
||||
rootView.trigger 'fuzzy-finder:find-under-cursor'
|
||||
|
||||
waitsFor ->
|
||||
finder.is(':visible')
|
||||
|
||||
runs ->
|
||||
expect(finder.find('.error').text().length).toBeGreaterThan 0
|
||||
|
||||
|
||||
describe "opening a path into a split", ->
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
|
||||
@@ -105,13 +105,20 @@ class FuzzyFinder extends SelectList
|
||||
editor = @rootView.getActiveEditor()
|
||||
range = editor.getCursor().getCurrentWordBufferRange(wordRegex: @filenameRegex)
|
||||
currentWord = editor.getTextInRange(range)
|
||||
if currentWord?
|
||||
@populateProjectPaths(filter: currentWord, done: (paths) =>
|
||||
if paths?.length == 1
|
||||
@rootView.open(paths[0])
|
||||
else if paths?.length
|
||||
|
||||
if currentWord.length == 0
|
||||
@attach()
|
||||
@setError('The cursor is not over a filename')
|
||||
else
|
||||
@populateProjectPaths filter: currentWord, done: (paths) =>
|
||||
if paths.length == 0
|
||||
@attach()
|
||||
@miniEditor.setText('' + currentWord))
|
||||
@setError('No files match \'currentWord\'')
|
||||
else if paths.length == 1
|
||||
@rootView.open(paths[0])
|
||||
else
|
||||
@attach()
|
||||
@miniEditor.setText(currentWord)
|
||||
|
||||
populateProjectPaths: (options = {}) ->
|
||||
if @projectPaths?.length > 0
|
||||
|
||||
Reference in New Issue
Block a user