From 5ea64f8b115d9b325c7b4cb21aee1aa303264ecc Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 2 Sep 2014 14:03:57 -0700 Subject: [PATCH] selectWord() -> selectWordsContainingCursors() --- spec/editor-spec.coffee | 14 +++++++------- src/editor-component.coffee | 2 +- src/editor.coffee | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 76605519d..2ccc4ca40 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -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()", -> diff --git a/src/editor-component.coffee b/src/editor-component.coffee index f31264dd2..ca04de86c 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -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() diff --git a/src/editor.coffee b/src/editor.coffee index 98bb53cd6..3d47bcc8d 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -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