mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
end/beginning word implementations are now more similar
This commit is contained in:
@@ -570,11 +570,16 @@ describe "EditSession", ->
|
||||
expect(editSession.getSelectedText()).toBe 'quicksort'
|
||||
|
||||
describe "when the cursor is between two words", ->
|
||||
it "selects the nearest word", ->
|
||||
it "selects the word the cursor is on", ->
|
||||
editSession.setCursorScreenPosition([0, 4])
|
||||
editSession.selectWord()
|
||||
expect(editSession.getSelectedText()).toBe 'quicksort'
|
||||
|
||||
editSession.setCursorScreenPosition([0, 3])
|
||||
editSession.selectWord()
|
||||
expect(editSession.getSelectedText()).toBe 'var'
|
||||
|
||||
|
||||
describe "when the cursor is inside a region of whitespace", ->
|
||||
it "selects the whitespace region", ->
|
||||
editSession.setCursorScreenPosition([5, 2])
|
||||
|
||||
@@ -173,10 +173,9 @@ class Cursor
|
||||
|
||||
endOfWordPosition = null
|
||||
@editSession.scanInRange (options.wordRegex ? @wordRegExp()), range, (match, matchRange, { stop }) =>
|
||||
endOfWordPosition = matchRange.end
|
||||
if matchRange.start.isGreaterThan(currentBufferPosition) and not allowNext
|
||||
endOfWordPosition = currentBufferPosition
|
||||
if not endOfWordPosition.isEqual(currentBufferPosition)
|
||||
if matchRange.start.isLessThanOrEqual(currentBufferPosition) or allowNext
|
||||
endOfWordPosition = matchRange.end
|
||||
if not endOfWordPosition?.isEqual(currentBufferPosition)
|
||||
stop()
|
||||
|
||||
endOfWordPosition or currentBufferPosition
|
||||
|
||||
Reference in New Issue
Block a user