Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Fix select-word command between word and non-word chararacters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nathan Sobo committed Nov 2, 2017
1 parent 6277459 commit 1e9753d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions spec/text-editor-spec.js
Expand Up @@ -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')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/cursor.js
Expand Up @@ -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 =>
Expand Down

0 comments on commit 1e9753d

Please sign in to comment.