From 1e9753d8a54a027c5902be0c9f8b10c665f271ec Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 2 Nov 2017 10:22:22 -0600 Subject: [PATCH] Fix select-word command between word and non-word chararacters In #15776, we accidentally stopped passing an option to the wordRegExp method that caused us to prefer word characters when selecting words at a boundary between word and non-word characters. --- spec/text-editor-spec.js | 8 ++++++-- src/cursor.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/text-editor-spec.js b/spec/text-editor-spec.js index cece5d753..382d020d4 100644 --- a/spec/text-editor-spec.js +++ b/spec/text-editor-spec.js @@ -2007,13 +2007,17 @@ describe('TextEditor', () => { describe('when the cursor is between two words', () => { it('selects the word the cursor is on', () => { - editor.setCursorScreenPosition([0, 4]) + editor.setCursorBufferPosition([0, 4]) editor.selectWordsContainingCursors() expect(editor.getSelectedText()).toBe('quicksort') - editor.setCursorScreenPosition([0, 3]) + editor.setCursorBufferPosition([0, 3]) editor.selectWordsContainingCursors() expect(editor.getSelectedText()).toBe('var') + + editor.setCursorBufferPosition([1, 22]) + editor.selectWordsContainingCursors() + expect(editor.getSelectedText()).toBe('items') }) }) diff --git a/src/cursor.js b/src/cursor.js index 6cd0cc623..10bdef804 100644 --- a/src/cursor.js +++ b/src/cursor.js @@ -594,7 +594,7 @@ class Cursor extends Model { getCurrentWordBufferRange (options = {}) { const position = this.getBufferPosition() const ranges = this.editor.buffer.findAllInRangeSync( - options.wordRegex || this.wordRegExp(), + options.wordRegex || this.wordRegExp(options), new Range(new Point(position.row, 0), new Point(position.row, Infinity)) ) const range = ranges.find(range =>