diff --git a/package.json b/package.json index 8cca44bf7..6c667f3c9 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "space-pen": "3.8.2", "stacktrace-parser": "0.1.1", "temp": "0.8.1", - "text-buffer": "6.3.7", + "text-buffer": "6.3.8", "theorist": "^1.0.2", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 8bbf722c2..641431d5a 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -4627,13 +4627,14 @@ describe "TextEditor", -> expect(cursor4.getBufferPosition()).toEqual([3,0]) editor.deleteToEndOfSubword() - expect(buffer.lineForRow(0)).toBe('Word ') - expect(buffer.lineForRow(1)).toBe('e, ') - expect(buffer.lineForRow(2)).toBe('') + expect(buffer.lineForRow(0)).toBe('') + expect(buffer.lineForRow(1)).toBe('Word ') + expect(buffer.lineForRow(2)).toBe('e,') + expect(buffer.lineForRow(3)).toBe(' ') expect(cursor1.getBufferPosition()).toEqual([0,0]) - expect(cursor2.getBufferPosition()).toEqual([0,0]) - expect(cursor3.getBufferPosition()).toEqual([1,2]) - expect(cursor4.getBufferPosition()).toEqual([1,2]) + expect(cursor2.getBufferPosition()).toEqual([1,0]) + expect(cursor3.getBufferPosition()).toEqual([2,2]) + expect(cursor4.getBufferPosition()).toEqual([3,0]) describe 'gutters', -> describe 'the TextEditor constructor', -> diff --git a/src/cursor.coffee b/src/cursor.coffee index b6b07dbf2..61f12cc8c 100644 --- a/src/cursor.coffee +++ b/src/cursor.coffee @@ -403,9 +403,6 @@ class Cursor extends Model moveToPreviousSubwordBoundary: -> options = {wordRegex: @subwordRegExp(backwards: true)} if position = @getPreviousWordBoundaryBufferPosition(options) - # HACK: to fix going left on first line - if position.isEqual(@getBufferPosition()) - position = new Point(position.row, 0) @setBufferPosition(position) # Public: Moves the cursor to the next subword boundary. @@ -448,7 +445,7 @@ class Cursor extends Model getPreviousWordBoundaryBufferPosition: (options = {}) -> currentBufferPosition = @getBufferPosition() previousNonBlankRow = @editor.buffer.previousNonBlankRow(currentBufferPosition.row) - scanRange = [[previousNonBlankRow, 0], currentBufferPosition] + scanRange = [[previousNonBlankRow ? 0, 0], currentBufferPosition] beginningOfWordPosition = null @editor.backwardsScanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) -> @@ -660,10 +657,14 @@ class Cursor extends Model # Returns a {RegExp}. subwordRegExp: (options={}) -> nonWordCharacters = atom.config.get('editor.nonWordCharacters', scope: @getScopeDescriptor()) - segments = ["^[\t ]*$"] - segments.push("[A-Z]?[a-z]+") - segments.push("[A-Z]+(?![a-z])") - segments.push("\\d+") + segments = [ + "^[\t ]+", + "[\t ]+$", + "[A-Z]?[a-z]+", + "[A-Z]+(?![a-z])", + "\\d+", + "_+" + ] if options.backwards segments.push("[#{_.escapeRegExp(nonWordCharacters)}]+\\s*") else