diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/AbstractJetUpDownMover.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/AbstractJetUpDownMover.java index 1e81b14fa56..16902a3b4ed 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/AbstractJetUpDownMover.java +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/upDownMover/AbstractJetUpDownMover.java @@ -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; } diff --git a/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt new file mode 100644 index 00000000000..4fd37383aed --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt @@ -0,0 +1,7 @@ +// MOVE: down +fun main(args: Array) { +run { + println() +} + +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt.after new file mode 100644 index 00000000000..790e7ceca80 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces1.kt.after @@ -0,0 +1,7 @@ +// MOVE: down +fun main(args: Array) { + +run { + println() +} +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt new file mode 100644 index 00000000000..ba3a2a5e502 --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt @@ -0,0 +1,7 @@ +// MOVE: up +fun main(args: Array) { + +run { + println() +} +} \ No newline at end of file diff --git a/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt.after b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt.after new file mode 100644 index 00000000000..dafa58e2bff --- /dev/null +++ b/idea/testData/codeInsight/moveUpDown/expressions/closureWthoutSpaces2.kt.after @@ -0,0 +1,7 @@ +// MOVE: up +fun main(args: Array) { +run { + println() +} + +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java index 7666e80dbd4..3864131f9e6 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/moveUpDown/CodeMoverTestGenerated.java @@ -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");