fixed PY-10995 Wrapping on right margin deletes code with slashes at the end of miltiline statements.

If we didn't process auto-formatted events from document - document could be broken by replacement.
Do not insert replacement string to the broken textrange
This commit is contained in:
Ekaterina Tuzova
2013-10-02 20:38:30 +04:00
parent baec2af48e
commit b5165a7e49
3 changed files with 29 additions and 0 deletions
@@ -0,0 +1,4 @@
def do_stuff():
another_long_variable = a_really_long_function_name_with_parameters(12,
this_is_the_first_param=23,
this_is_the_second=45).do_more_stuff_to_the_result()
+3
View File
@@ -0,0 +1,3 @@
def do_stuff():
another_long_variable = a_really_long_function_name_with_parameters(12,
<caret>this_is_the_first_param=23, this_is_the_second=45).do_more_stuff_to_the_result()
@@ -49,6 +49,28 @@ public class PyWrapTest extends PyTestCase {
doTest(" AND field");
}
public void testWrapRightMargin() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
int oldValue = settings.RIGHT_MARGIN;
boolean oldMarginValue = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
settings.RIGHT_MARGIN = 100;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
try {
final String testName = "wrap/" + getTestName(true);
myFixture.configureByFile(testName + ".py");
for (int i = 0; i != 45; ++i) {
myFixture.type(' ');
}
myFixture.checkResultByFile(testName + ".after.py");
}
finally {
settings.RIGHT_MARGIN = oldValue;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = oldMarginValue;
}
}
private void doTest(final String textToType) {
myFixture.configureByFile("wrap/" + getTestName(false) + ".py");
myFixture.type(textToType);