mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-5197 Move statement: inconsistent skipping of empty lines
This commit is contained in:
+12
@@ -88,6 +88,7 @@ public class StatementMover extends LineMover {
|
||||
info.toMove2 = new LineRange(myStatementToMove);
|
||||
}
|
||||
if (isMoveToCompound(info, editor, file, down)) {
|
||||
if (isMoveToEmptyLine(editor, info)) return true;
|
||||
myStatementToIncreaseIndent = myStatementToMove;
|
||||
if (!down)
|
||||
info.toMove2 = new LineRange(myStatementToMove);
|
||||
@@ -157,7 +158,9 @@ public class StatementMover extends LineMover {
|
||||
info.toMove = range;
|
||||
info.toMove2 = new LineRange(nearLine, nearLine + 1);
|
||||
|
||||
if (isMoveToEmptyLine(editor, info)) return;
|
||||
// if try to move to the function or to the class
|
||||
|
||||
int offset2 = getLineStartSafeOffset(doc, info.toMove2.startLine);
|
||||
PsiElement element2 = file.findElementAt(offset2);
|
||||
if (element2 != null) {
|
||||
@@ -185,6 +188,15 @@ public class StatementMover extends LineMover {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMoveToEmptyLine(Editor editor, MoveInfo info) {
|
||||
Document document = editor.getDocument();
|
||||
if (document.getLineCount() > info.toMove2.endLine) {
|
||||
String lineToMoveTo = document.getText(new TextRange(getLineStartSafeOffset(document, info.toMove2.startLine), getLineStartSafeOffset(document, info.toMove2.endLine)));
|
||||
if (StringUtil.isEmptyOrSpaces(lineToMoveTo)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* main indent logic
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
if condition1:
|
||||
pass
|
||||
|
||||
if condi<caret>tion:
|
||||
test1()
|
||||
else:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
if condition1:
|
||||
pass
|
||||
|
||||
if condition:
|
||||
test1()
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
if True:
|
||||
a = 1
|
||||
|
||||
b =<caret> 2
|
||||
@@ -0,0 +1,4 @@
|
||||
if True:
|
||||
a = 1
|
||||
|
||||
b = 2
|
||||
@@ -0,0 +1,4 @@
|
||||
if True:
|
||||
a = 1
|
||||
b = 2
|
||||
|
||||
@@ -111,4 +111,8 @@ public class PyStatementMoverTest extends PyTestCase {
|
||||
public void testOneLineCompound() { // PY-5198
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEmptyLine() { // PY-5197
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user