mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
@@ -4450,13 +4450,16 @@ describe "TextEditor", ->
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 0])
|
||||
|
||||
it "stops at word and underscore boundaries", ->
|
||||
editor.setText("_word \n")
|
||||
editor.setCursorBufferPosition([0, 6])
|
||||
editor.setText("sub_word \n")
|
||||
editor.setCursorBufferPosition([0, 9])
|
||||
editor.moveToPreviousSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 5])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 8])
|
||||
|
||||
editor.moveToPreviousSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 1])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 4])
|
||||
|
||||
editor.moveToPreviousSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 0])
|
||||
|
||||
editor.setText(" word\n")
|
||||
editor.setCursorBufferPosition([0, 3])
|
||||
@@ -4526,13 +4529,16 @@ describe "TextEditor", ->
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 0])
|
||||
|
||||
it "stops at word and underscore boundaries", ->
|
||||
editor.setText(" word_ \n")
|
||||
editor.setText(" sub_word \n")
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.moveToNextSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 1])
|
||||
|
||||
editor.moveToNextSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 5])
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 4])
|
||||
|
||||
editor.moveToNextSubwordBoundary()
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0, 9])
|
||||
|
||||
editor.setText("word \n")
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
|
||||
@@ -657,18 +657,20 @@ class Cursor extends Model
|
||||
# Returns a {RegExp}.
|
||||
subwordRegExp: (options={}) ->
|
||||
nonWordCharacters = atom.config.get('editor.nonWordCharacters', scope: @getScopeDescriptor())
|
||||
snakeCamelSegment = "[A-Z]?[a-z]+"
|
||||
segments = [
|
||||
"^[\t ]+",
|
||||
"[\t ]+$",
|
||||
"[A-Z]?[a-z]+",
|
||||
"[A-Z]+(?![a-z])",
|
||||
"\\d+",
|
||||
"_+"
|
||||
"\\d+"
|
||||
]
|
||||
if options.backwards
|
||||
segments.push("#{snakeCamelSegment}_*")
|
||||
segments.push("[#{_.escapeRegExp(nonWordCharacters)}]+\\s*")
|
||||
else
|
||||
segments.push("_*#{snakeCamelSegment}")
|
||||
segments.push("\\s*[#{_.escapeRegExp(nonWordCharacters)}]+")
|
||||
segments.push("_+")
|
||||
new RegExp(segments.join("|"), "g")
|
||||
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user