Fix indenting of HTML (closing) tags for instance. Fix #1294

The indentation level is not anymore reduced by adding a new line,
which previously caused multiple reductions of the indentation level.
This fixes the behavior of HTML closing tags, which currently
"jump" backwards if you try to move them down.
This commit is contained in:
steffen
2014-05-31 13:32:14 +02:00
parent 61ee1be2cb
commit 437b0decab
2 changed files with 10 additions and 0 deletions

View File

@@ -1616,6 +1616,13 @@ describe "Editor", ->
expect(editor.lineForBufferRow(1)).toBe ' '
expect(editor.lineForBufferRow(2)).toBe '}'
describe "when a new line is appended before a closing tag (e.g. by pressing enter before a selection)", ->
it "moves the line down and keeps the indentation level the same when editor.autoIndent is true", ->
atom.config.set('editor.autoIndent', true)
editor.setCursorBufferPosition([9,2])
editor.insertNewline()
expect(editor.lineForBufferRow(10)).toBe ' };'
describe ".backspace()", ->
describe "when there is a single cursor", ->
changeScreenRangeHandler = null

View File

@@ -305,7 +305,10 @@ class Selection extends Model
if options.autoIndent
@editor.autoIndentBufferRow(row) for row in newBufferRange.getRows()
else if options.autoIndentNewline and text == '\n'
currentIndentation = @editor.indentationForBufferRow(newBufferRange.start.row)
@editor.autoIndentBufferRow(newBufferRange.end.row, preserveLeadingWhitespace: true)
if @editor.indentationForBufferRow(newBufferRange.end.row) < currentIndentation
@editor.setIndentationForBufferRow(newBufferRange.end.row, currentIndentation)
else if options.autoDecreaseIndent and /\S/.test text
@editor.autoDecreaseIndentForBufferRow(newBufferRange.start.row)