fixed PY-5198 Move statement: breaks code in case of one-line compound statements on module level

This commit is contained in:
Ekaterina Tuzova
2011-12-02 12:19:43 +01:00
parent 3c98006baf
commit a0b8b18a56
5 changed files with 17 additions and 0 deletions
@@ -325,6 +325,9 @@ public class StatementMover extends LineMover {
PsiElement whiteSpace = myStatementToAddLinebreak.getContainingFile().findElementAt(editor.getDocument().getLineStartOffset(line));
String indent = StringUtil.repeatSymbol(' ', indentOptions.INDENT_SIZE);
PyStatementWithElse statementWithElse = PsiTreeUtil.getParentOfType(myStatementToAddLinebreak, PyStatementWithElse.class);
if (statementWithElse != null && statementWithElse.getParent() instanceof PyFile) indent = "\n";
if (whiteSpace instanceof PsiWhiteSpace) indent += whiteSpace.getText();
if (down) indent += StringUtil.repeatSymbol(' ', indentOptions.INDENT_SIZE);
editor.getDocument().insertString(textRange.getStartOffset(), indent);
+3
View File
@@ -0,0 +1,3 @@
c = 1
if True: a = 1
b =<caret> 2
@@ -0,0 +1,3 @@
c = 1
if True: a = 1
b =<caret> 2
@@ -0,0 +1,4 @@
c = 1
if True:
a = 1
b = 2
@@ -107,4 +107,8 @@ public class PyStatementMoverTest extends PyTestCase {
public void testClass() { // PY-5196
doTest();
}
public void testOneLineCompound() { // PY-5198
doTest();
}
}