cmd-left moves the cursor to column 0 on lines only containing whitespace

Fixes #1344
This commit is contained in:
probablycorey
2013-12-30 13:54:04 -08:00
parent 8e970b64b8
commit bac76784e0
2 changed files with 8 additions and 3 deletions

View File

@@ -432,6 +432,13 @@ describe "Editor", ->
expect(cursor1.getBufferPosition()).toEqual [0,0]
expect(cursor2.getBufferPosition()).toEqual [1,0]
it "moves to the beginning of the line if it only contains whitespace ", ->
editor.setText("first\n \nthird")
editor.setCursorScreenPosition [1,2]
editor.moveCursorToFirstCharacterOfLine()
cursor = editor.getCursor()
expect(cursor.getBufferPosition()).toEqual [1,0]
describe ".moveCursorToBeginningOfWord()", ->
it "moves the cursor to the beginning of the word", ->
editor.setCursorBufferPosition [0, 8]

View File

@@ -261,9 +261,7 @@ class Cursor
screenline = @editor.lineForScreenRow(row)
goalColumn = screenline.text.search(/\S/)
return if goalColumn == -1
goalColumn = 0 if goalColumn == column
goalColumn = 0 if goalColumn == column or goalColumn == -1
@setScreenPosition([row, goalColumn])
# Public: Moves the cursor to the beginning of the buffer line, skipping all