Rename wordSeparators to nonWordCharacters

This commit is contained in:
Corey Johnson
2013-01-29 17:06:39 -08:00
parent 46aefc75ab
commit 167b9c28fa
2 changed files with 6 additions and 7 deletions

View File

@@ -147,9 +147,9 @@ class Cursor
if position = @getEndOfCurrentWordBufferPosition()
@setBufferPosition(position)
wordSeparatorsRegExp: ->
wordSeparators = config.get("editor.wordSeparators")
new RegExp("^[\t ]*$|[^\\s#{_.escapeRegExp(wordSeparators)}]+|[#{_.escapeRegExp(wordSeparators)}]+", "mg")
wordRegExp: ->
nonWordCharacters = config.get("editor.nonWordCharacters")
new RegExp("^[\t ]*$|[^\\s#{_.escapeRegExp(nonWordCharacters)}]+|[#{_.escapeRegExp(nonWordCharacters)}]+", "mg")
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
allowPrevious = options.allowPrevious ? true
@@ -159,7 +159,7 @@ class Cursor
beginningOfWordPosition = currentBufferPosition
@editSession.backwardsScanInRange (options.wordRegex ? @wordSeparatorsRegExp()), previousLinesRange, (match, matchRange, { stop }) =>
@editSession.backwardsScanInRange (options.wordRegex ? @wordRegExp()), previousLinesRange, (match, matchRange, { stop }) =>
if matchRange.end.isGreaterThanOrEqual(currentBufferPosition) or allowPrevious
beginningOfWordPosition = matchRange.start
stop() unless beginningOfWordPosition.isEqual(currentBufferPosition)
@@ -172,7 +172,7 @@ class Cursor
range = [currentBufferPosition, @editSession.getEofBufferPosition()]
endOfWordPosition = null
@editSession.scanInRange (options.wordRegex ? @wordSeparatorsRegExp()),
@editSession.scanInRange (options.wordRegex ? @wordRegExp()),
range, (match, matchRange, { stop }) =>
endOfWordPosition = matchRange.end
return if endOfWordPosition.isEqual(currentBufferPosition)

View File

@@ -19,8 +19,7 @@ class Editor extends View
autosave: false
autoIndent: true
autoIndentOnPaste: false
wordRegex: /(\w+)|([^\w\n]+)/g
wordSeparators: "./\()\"-:,.;<>~!@#$%^&*|+=[]{}`~?"
nonWordCharacters: "./\()\"-:,.;<>~!@#$%^&*|+=[]{}`~?"
@content: (params) ->
@div class: @classes(params), tabindex: -1, =>