KT-3736 Fixed: "Move Statement Down doesn't work to improperly formatted code"
This commit is contained in:
+8
-2
@@ -47,9 +47,15 @@ public abstract class AbstractJetUpDownMover extends LineMover {
|
||||
LineRange lineRange2 = getElementSourceLineRange(combinedRange.second, editor, oldRange);
|
||||
if (lineRange2 == null) return null;
|
||||
|
||||
LineRange parentLineRange = getElementSourceLineRange(parent, editor, oldRange);
|
||||
|
||||
LineRange sourceRange = new LineRange(lineRange1.startLine, lineRange2.endLine);
|
||||
sourceRange.firstElement = combinedRange.first;
|
||||
sourceRange.lastElement = combinedRange.second;
|
||||
if (parentLineRange != null && sourceRange.contains(parentLineRange)) {
|
||||
sourceRange.firstElement = sourceRange.lastElement = parent;
|
||||
} else {
|
||||
sourceRange.firstElement = combinedRange.first;
|
||||
sourceRange.lastElement = combinedRange.second;
|
||||
}
|
||||
|
||||
return sourceRange;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// MOVE: down
|
||||
fun main(args: Array<String>) {
|
||||
<caret>run {
|
||||
println()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// MOVE: down
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
<caret>run {
|
||||
println()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// MOVE: up
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
<caret>run {
|
||||
println()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// MOVE: up
|
||||
fun main(args: Array<String>) {
|
||||
<caret>run {
|
||||
println()
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -817,6 +817,16 @@ public class CodeMoverTestGenerated extends AbstractCodeMoverTest {
|
||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureInWhile2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("closureWthoutSpaces1.kt")
|
||||
public void testClosureWthoutSpaces1() throws Exception {
|
||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("closureWthoutSpaces2.kt")
|
||||
public void testClosureWthoutSpaces2() throws Exception {
|
||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declaration1.kt")
|
||||
public void testDeclaration1() throws Exception {
|
||||
doTestExpression("idea/testData/codeInsight/moveUpDown/expressions/declaration1.kt");
|
||||
|
||||
Reference in New Issue
Block a user