mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-5198 Move statement: breaks code in case of one-line compound statements on module level
This commit is contained in:
+3
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user