mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Move cursor to end of line when on first row
This line may be indented now so move the cursor to the end of the indentation.
This commit is contained in:
@@ -1426,6 +1426,15 @@ describe "Editor", ->
|
||||
|
||||
it "indents the new line to the same indent level as the current line when editor.autoIndent is true", ->
|
||||
atom.config.set('editor.autoIndent', true)
|
||||
|
||||
editor.setText(' var test')
|
||||
editor.setCursorBufferPosition([0,2])
|
||||
editor.insertNewlineAbove()
|
||||
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0,2]
|
||||
expect(editor.lineForBufferRow(0)).toBe ' '
|
||||
expect(editor.lineForBufferRow(1)).toBe ' var test'
|
||||
|
||||
editor.setText('\n var test')
|
||||
editor.setCursorBufferPosition([1,2])
|
||||
editor.insertNewlineAbove()
|
||||
|
||||
@@ -625,11 +625,15 @@ class Editor extends Model
|
||||
bufferRow = @getCursorBufferPosition().row
|
||||
indentLevel = @indentationForBufferRow(bufferRow)
|
||||
onFirstLine = bufferRow is 0
|
||||
|
||||
@moveCursorToBeginningOfLine()
|
||||
@moveCursorLeft()
|
||||
@insertNewline()
|
||||
@setIndentationForBufferRow(bufferRow, indentLevel) if @shouldAutoIndent()
|
||||
@moveCursorUp() if onFirstLine
|
||||
|
||||
if onFirstLine
|
||||
@moveCursorUp()
|
||||
@moveCursorToEndOfLine()
|
||||
|
||||
# Indent all lines intersecting selections. See {Selection::indent} for more
|
||||
# information.
|
||||
|
||||
Reference in New Issue
Block a user