From aa8b97a039b41d25794d669ce03cff0f21b62781 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 1 Jan 2015 23:02:24 -0800 Subject: [PATCH] Respect options to Cursor::getBeginningOfNextWordBufferPosition --- src/cursor.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cursor.coffee b/src/cursor.coffee index 421ddc014..6c16082b8 100644 --- a/src/cursor.coffee +++ b/src/cursor.coffee @@ -206,10 +206,16 @@ class Cursor extends Model _.contains(nonWordCharacters, before) isnt _.contains(nonWordCharacters, after) # Public: Returns whether this cursor is between a word's start and end. - isInsideWord: -> + # + # * `options` (optional) {Object} + # * `wordRegex` A {RegExp} indicating what constitutes a "word" + # (default: {::wordRegExp}). + # + # Returns a {Boolean} + isInsideWord: (options) -> {row, column} = @getBufferPosition() range = [[row, column], [row, Infinity]] - @editor.getTextInBufferRange(range).search(@wordRegExp()) == 0 + @editor.getTextInBufferRange(range).search(options?.wordRegex ? @wordRegExp()) == 0 # Public: Returns the indentation level of the current line. getIndentLevel: -> @@ -544,7 +550,7 @@ class Cursor extends Model # Returns a {Range} getBeginningOfNextWordBufferPosition: (options = {}) -> currentBufferPosition = @getBufferPosition() - start = if @isInsideWord() then @getEndOfCurrentWordBufferPosition() else currentBufferPosition + start = if @isInsideWord(options) then @getEndOfCurrentWordBufferPosition(options) else currentBufferPosition scanRange = [start, @editor.getEofBufferPosition()] beginningOfNextWordPosition = null