mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add getWordUnderCursor to Editor and EditSession
This commit is contained in:
@@ -498,6 +498,9 @@ class EditSession
|
||||
getCurrentParagraphBufferRange: ->
|
||||
@getCursor().getCurrentParagraphBufferRange()
|
||||
|
||||
getWordUnderCursor: (options) ->
|
||||
@getTextInBufferRange(@getCursor().getCurrentWordBufferRange(options))
|
||||
|
||||
moveCursorUp: (lineCount) ->
|
||||
@moveCursors (cursor) -> cursor.moveUp(lineCount)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user