Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17636 from atom/fb-mdt-reset-goal-column-on-home
Browse files Browse the repository at this point in the history
Reset goal column on all cursor changes
  • Loading branch information
Max Brunsfeld committed Jul 6, 2018
2 parents 9886fa1 + f60f169 commit bb3cce9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/text-editor-spec.js
Expand Up @@ -861,6 +861,15 @@ describe('TextEditor', () => {
})
})
})

it("clears the goal column", () => {
editor.setText('first\n\nthird')
editor.setCursorScreenPosition([0, 3])
editor.moveDown()
editor.moveToFirstCharacterOfLine()
editor.moveDown()
expect(editor.getCursorBufferPosition()).toEqual([2, 0])
})
})

describe('.moveToBeginningOfWord()', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/cursor.js
Expand Up @@ -326,7 +326,9 @@ class Cursor extends Model {

// Public: Moves the cursor to the bottom of the buffer.
moveToBottom () {
const column = this.goalColumn
this.setBufferPosition(this.editor.getEofBufferPosition())
this.goalColumn = column
}

// Public: Moves the cursor to the beginning of the line.
Expand Down Expand Up @@ -711,6 +713,7 @@ class Cursor extends Model {
changePosition (options, fn) {
this.clearSelection({autoscroll: false})
fn()
this.goalColumn = null
const autoscroll = (options && options.autoscroll != null)
? options.autoscroll
: this.isLastCursor()
Expand Down

0 comments on commit bb3cce9

Please sign in to comment.