Merge pull request #17636 from atom/fb-mdt-reset-goal-column-on-home

Reset goal column on all cursor changes
This commit is contained in:
Max Brunsfeld
2018-07-06 11:39:37 -07:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -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()', () => {

View File

@@ -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.
@@ -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()