mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
If inserting on a line that is longer than the suggested indent, preserve indent
This commit is contained in:
@@ -742,6 +742,13 @@ describe "EditSession", ->
|
||||
|
||||
describe "when the cursor's current column is greater than the suggested indent level", ->
|
||||
it "preserves the current indent level, indenting all lines relative to it", ->
|
||||
editSession.insertText('\n ')
|
||||
editSession.insertText(text, normalizeIndent: true)
|
||||
|
||||
expect(editSession.lineForBufferRow(3)).toBe " while (true) {"
|
||||
expect(editSession.lineForBufferRow(4)).toBe " foo();"
|
||||
expect(editSession.lineForBufferRow(5)).toBe " }"
|
||||
expect(editSession.lineForBufferRow(6)).toBe " bar();"
|
||||
|
||||
describe "if auto-indent is disabled", ->
|
||||
it "always normalizes indented lines to the cursor's current indentation level", ->
|
||||
|
||||
@@ -168,11 +168,11 @@ class Selection
|
||||
normalizedLines.join('\n')
|
||||
|
||||
adjustIndentationForLine: (line, delta) ->
|
||||
indentText = new Array(Math.abs(delta + 1)).join(' ')
|
||||
indentText = new Array(Math.abs(delta) + 1).join(' ')
|
||||
if delta > 0
|
||||
indentText + line
|
||||
else if delta < 0
|
||||
line.replace(indentText, '')
|
||||
line.replace(new RegExp("^#{indentText}"), '')
|
||||
else
|
||||
line
|
||||
|
||||
|
||||
Reference in New Issue
Block a user