mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-5201 Move statement: changes code logic on moving one-line compound statement outside nested one
This commit is contained in:
+7
-2
@@ -339,8 +339,13 @@ public class StatementMover extends LineMover {
|
||||
getCurrentSettings().getIndentOptions(PythonFileType.INSTANCE);
|
||||
assert indentOptions != null;
|
||||
final Document document = editor.getDocument();
|
||||
TextRange textRange = myStatementToDecreaseIndent.getTextRange();
|
||||
document.deleteString(textRange.getStartOffset()-indentOptions.INDENT_SIZE, textRange.getStartOffset());
|
||||
final int startLine = editor.offsetToLogicalPosition(myStatementToDecreaseIndent.getTextRange().getStartOffset()).line;
|
||||
final int endLine = editor.offsetToLogicalPosition(myStatementToDecreaseIndent.getTextRange().getEndOffset()).line;
|
||||
for (int line = startLine; line <= endLine; ++line) {
|
||||
final int offset = document.getLineStartOffset(line);
|
||||
document.deleteString(offset, offset + indentOptions.INDENT_SIZE);
|
||||
}
|
||||
|
||||
myStatementToDecreaseIndent = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
if condition:
|
||||
pass
|
||||
elif other_condition:
|
||||
if another_one:
|
||||
if T<caret>rue: a = 1 # <- move statement up here
|
||||
else: b = 2
|
||||
@@ -0,0 +1,6 @@
|
||||
if condition:
|
||||
pass
|
||||
elif other_condition:
|
||||
if another_one:
|
||||
if T<caret>rue: a = 1 # <- move statement up here
|
||||
else: b = 2
|
||||
@@ -0,0 +1,7 @@
|
||||
if condition:
|
||||
pass
|
||||
elif other_condition:
|
||||
if T<caret>rue: a = 1 # <- move statement up here
|
||||
else: b = 2
|
||||
if another_one:
|
||||
pass
|
||||
@@ -121,6 +121,10 @@ public class PyStatementMoverTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOneLineCompoundOutside() { // PY-5201
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWith() { // PY-5202
|
||||
try {
|
||||
setLanguageLevel(LanguageLevel.PYTHON27);
|
||||
|
||||
Reference in New Issue
Block a user