Don't strip newline when buffer is a single newline

This commit is contained in:
Kevin Sawicki
2012-12-29 10:44:39 -08:00
parent e1db5432dd
commit 1956b98995
2 changed files with 8 additions and 3 deletions

View File

@@ -64,3 +64,8 @@ describe "StripTrailingWhitespace", ->
editor.insertText ""
editor.save()
expect(editor.getText()).toBe ""
it "leaves a buffer that is a single newline untouched", ->
editor.insertText "\n"
editor.save()
expect(editor.getText()).toBe "\n"

View File

@@ -15,8 +15,8 @@ module.exports =
replace('')
if config.get('stripTrailingWhitespace.singleTrailingNewline')
if buffer.getLastLine() is ''
row = buffer.getLastRow()
while row and buffer.lineForRow(--row) is ''
buffer.deleteRow(row)
row = buffer.getLastRow() - 1
while row and buffer.lineForRow(row) is ''
buffer.deleteRow(row--)
else
buffer.append('\n')