PY-12360 Fix test data in remaining tests, commit document after modification

This commit is contained in:
Mikhail Golubev
2015-04-27 20:34:51 +03:00
parent 15cf5b06f6
commit ec61bd4736
10 changed files with 24 additions and 19 deletions
@@ -64,7 +64,7 @@ public class PyTrailingBlankLinesPostFormatProcessor implements PostFormatProces
if (rangeToReformat.intersects(oldWhitespaceRange)) {
final TextRange newWhitespaceRange = replaceOrDeleteTrailingWhitespaces((PyFile)source, oldWhitespaceRange);
final int delta = newWhitespaceRange.getLength() - oldWhitespaceRange.getLength();
if (newWhitespaceRange.contains(oldWhitespaceRange)) {
if (oldWhitespaceRange.contains(rangeToReformat)) {
return newWhitespaceRange;
}
else if (rangeToReformat.contains(oldWhitespaceRange)) {
@@ -109,19 +109,24 @@ public class PyTrailingBlankLinesPostFormatProcessor implements PostFormatProces
numLineFeeds = 1;
}
documentManager.doPostponedOperationsAndUnblockDocument(document);
final String text = StringUtil.repeat("\n", numLineFeeds);
if (numLineFeeds > 0 && whitespaceRange.getStartOffset() != 0) {
if (!whitespaceRange.isEmpty()) {
document.replaceString(whitespaceRange.getStartOffset(), whitespaceRange.getEndOffset(), text);
try {
final String text = StringUtil.repeat("\n", numLineFeeds);
if (numLineFeeds > 0 && whitespaceRange.getStartOffset() != 0) {
if (!whitespaceRange.isEmpty()) {
document.replaceString(whitespaceRange.getStartOffset(), whitespaceRange.getEndOffset(), text);
}
else {
document.insertString(document.getTextLength(), text);
}
}
else {
document.insertString(document.getTextLength(), text);
else if (!whitespaceRange.isEmpty()) {
document.deleteString(whitespaceRange.getStartOffset(), whitespaceRange.getEndOffset());
}
return TextRange.from(whitespaceRange.getStartOffset(), text.length());
}
else if (!whitespaceRange.isEmpty()) {
document.deleteString(whitespaceRange.getStartOffset(), whitespaceRange.getEndOffset());
finally {
documentManager.commitDocument(document);
}
return TextRange.from(whitespaceRange.getStartOffset(), text.length());
}
return whitespaceRange;
}
@@ -2,4 +2,4 @@ example = {'breakfast': {
'eggs': 1,
'spam': 2
}
}
}
@@ -1 +1 @@
a.method().strip()
a.method().strip()
@@ -22,4 +22,4 @@ voo = 10 + 10
woo = 10 + 10
xoo = 10 + 10
yoo = 10 + 10
zoo = 10 + 10
zoo = 10 + 10
@@ -1 +1 @@
boo = (100 + 100) * 100
boo = (100 + 100) * 100
@@ -2,4 +2,4 @@ def foo(arg):
print arg
foo(('a', 'b'))
foo(('a', 'b'))
@@ -1,3 +1,3 @@
class C:
def foo(self):
return Conference()
return Conference()
@@ -1,3 +1,3 @@
print ('spam!' * 42)
('spam!' * 42)
hex('spam!' * 42)
hex('spam!' * 42)
@@ -1,3 +1,3 @@
result = '123456789|123456789|123456789|123456789|123456789|' + \
'123456789|123456789|123456789|123456789|123456789|' + \
'123456789|123456789|123456789|123456789|123456789|'
'123456789|123456789|123456789|123456789|123456789|'
@@ -1 +1 @@
boo = 10
boo = 10