Add getWordUnderCursor to Editor and EditSession

This commit is contained in:
Corey Johnson
2013-01-21 15:19:01 -08:00
parent ad8a29df80
commit 32e281bcc6
3 changed files with 7 additions and 4 deletions

View File

@@ -498,6 +498,9 @@ class EditSession
getCurrentParagraphBufferRange: ->
@getCursor().getCurrentParagraphBufferRange()
getWordUnderCursor: (options) ->
@getTextInBufferRange(@getCursor().getCurrentWordBufferRange(options))
moveCursorUp: (lineCount) ->
@moveCursors (cursor) -> cursor.moveUp(lineCount)

View File

@@ -209,6 +209,7 @@ class Editor extends View
setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options)
getCursorBufferPosition: -> @activeEditSession.getCursorBufferPosition()
getCurrentParagraphBufferRange: -> @activeEditSession.getCurrentParagraphBufferRange()
getWordUnderCursor: (options) -> @activeEditSession.getWordUnderCursor(options)
getSelection: (index) -> @activeEditSession.getSelection(index)
getSelections: -> @activeEditSession.getSelections()

View File

@@ -103,17 +103,16 @@ class FuzzyFinder extends SelectList
return unless @rootView.project.getPath()?
@allowActiveEditorChange = false
editor = @rootView.getActiveEditor()
range = editor.getCursor().getCurrentWordBufferRange(wordRegex: @filenameRegex)
currentWord = editor.getTextInRange(range)
currentWord = editor.getWordUnderCursor(wordRegex: @filenameRegex)
if currentWord.length == 0
@attach()
@setError('The cursor is not over a filename')
@setError("The cursor is not over a filename")
else
@populateProjectPaths filter: currentWord, done: (paths) =>
if paths.length == 0
@attach()
@setError('No files match \'currentWord\'')
@setError("No files match '#{currentWord}'")
else if paths.length == 1
@rootView.open(paths[0])
else