mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Only indent the line following a '\n' not the line preceding it
This commit is contained in:
@@ -2369,6 +2369,18 @@ describe "EditSession", ->
|
||||
editSession.insertText('\n')
|
||||
expect(editSession.indentationForBufferRow(6)).toBe editSession.indentationForBufferRow(5)
|
||||
|
||||
it "does not indent the line preceding the newline", ->
|
||||
config.set("editor.autoIndent", true)
|
||||
editSession.setCursorBufferPosition([2, 0])
|
||||
editSession.insertText(' var this-line-should-be-indented-more\n')
|
||||
expect(editSession.indentationForBufferRow(1)).toBe 1
|
||||
|
||||
config.set("editor.autoIndent", true)
|
||||
editSession.setCursorBufferPosition([2, Infinity])
|
||||
editSession.insertText('\n')
|
||||
expect(editSession.indentationForBufferRow(1)).toBe 1
|
||||
expect(editSession.indentationForBufferRow(2)).toBe 1
|
||||
|
||||
describe "when inserted text matches a decrease indent pattern", ->
|
||||
describe "when the preceding line matches an increase indent pattern", ->
|
||||
it "decreases the indentation of the line to match that of the preceding line", ->
|
||||
|
||||
@@ -273,8 +273,10 @@ class Selection
|
||||
else
|
||||
@cursor.setBufferPosition(newBufferRange.end, skipAtomicTokens: true) if wasReversed
|
||||
|
||||
if options.autoIndent or (options.autoIndentNewline and text == '\n')
|
||||
if options.autoIndent
|
||||
@editSession.autoIndentBufferRow(row) for row in newBufferRange.getRows()
|
||||
else if options.autoIndentNewline and text == '\n'
|
||||
@editSession.autoIndentBufferRow(newBufferRange.end.row)
|
||||
else if options.autoDecreaseIndent and /\S/.test text
|
||||
@editSession.autoDecreaseIndentForRow(newBufferRange.start.row)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user