PY-12360 Do not add extra blank line at the end of empty file

This commit is contained in:
Mikhail Golubev
2015-04-27 20:34:50 +03:00
parent a8e89d53cb
commit 15cf5b06f6
4 changed files with 6 additions and 1 deletions
@@ -110,7 +110,7 @@ public class PyTrailingBlankLinesPostFormatProcessor implements PostFormatProces
}
documentManager.doPostponedOperationsAndUnblockDocument(document);
final String text = StringUtil.repeat("\n", numLineFeeds);
if (numLineFeeds > 0) {
if (numLineFeeds > 0 && whitespaceRange.getStartOffset() != 0) {
if (!whitespaceRange.isEmpty()) {
document.replaceString(whitespaceRange.getStartOffset(), whitespaceRange.getEndOffset(), text);
}
@@ -562,6 +562,11 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
// PY-11552
public void testTrailingBlankLinesInEmptyFile() {
doTest();
}
// PY-15530
public void testAlignmentInArgumentListWhereFirstArgumentIsEmptyCall() {
doTest();