selectWord() -> selectWordsContainingCursors()

This commit is contained in:
Ben Ogle 2014-09-02 14:03:57 -07:00
parent 70af6198bd
commit 5ea64f8b11
3 changed files with 13 additions and 10 deletions

View File

@ -1158,39 +1158,39 @@ describe "Editor", ->
expect(selection4.getBufferRange()).toEqual [[3,30], [3,31]]
expect(selection4.isReversed()).toBeFalsy()
describe ".selectWord()", ->
describe ".selectWordsContainingCursors()", ->
describe "when the cursor is inside a word", ->
it "selects the entire word", ->
editor.setCursorScreenPosition([0, 8])
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedText()).toBe 'quicksort'
describe "when the cursor is between two words", ->
it "selects the word the cursor is on", ->
editor.setCursorScreenPosition([0, 4])
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedText()).toBe 'quicksort'
editor.setCursorScreenPosition([0, 3])
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedText()).toBe 'var'
describe "when the cursor is inside a region of whitespace", ->
it "selects the whitespace region", ->
editor.setCursorScreenPosition([5, 2])
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedBufferRange()).toEqual [[5, 0], [5, 6]]
editor.setCursorScreenPosition([5, 0])
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedBufferRange()).toEqual [[5, 0], [5, 6]]
describe "when the cursor is at the end of the text", ->
it "select the previous word", ->
editor.buffer.append 'word'
editor.moveToBottom()
editor.selectWord()
editor.selectWordsContainingCursors()
expect(editor.getSelectedBufferRange()).toEqual [[12, 2], [12, 6]]
describe ".selectToFirstCharacterOfLine()", ->

View File

@ -416,7 +416,7 @@ EditorComponent = React.createClass
'core:copy': -> editor.copySelectedText()
'core:paste': -> editor.pasteText()
'editor:move-to-previous-word': -> editor.moveToPreviousWord()
'editor:select-word': -> editor.selectWord()
'editor:select-word': -> editor.selectWordsContainingCursors()
'editor:consolidate-selections': @consolidateSelections
'editor:delete-to-beginning-of-word': -> editor.deleteToBeginningOfWord()
'editor:delete-to-beginning-of-line': -> editor.deleteToBeginningOfLine()

View File

@ -2028,9 +2028,12 @@ class Editor extends Model
deprecate('Use Editor::selectLinesContainingCursors instead')
@selectLinesContainingCursors()
# Essential: Select the word containing each cursor.
selectWord: ->
# Essential: Select the word surrounding each cursor.
selectWordsContainingCursors: ->
@expandSelectionsForward (selection) -> selection.selectWord()
selectWord: ->
deprecate('Use Editor::selectWordsContainingCursors instead')
@selectWordsContainingCursors()
# Selection Extended