NPE in Surround with Action on empty line
This commit is contained in:
@@ -73,6 +73,8 @@ public class CodeInsightUtils {
|
|||||||
startOffset = element1.getTextRange().getStartOffset();
|
startOffset = element1.getTextRange().getStartOffset();
|
||||||
endOffset = element2.getTextRange().getEndOffset();
|
endOffset = element2.getTextRange().getEndOffset();
|
||||||
|
|
||||||
|
if (startOffset >= endOffset) return PsiElement.EMPTY_ARRAY;
|
||||||
|
|
||||||
PsiElement parent = PsiTreeUtil.findCommonParent(element1, element2);
|
PsiElement parent = PsiTreeUtil.findCommonParent(element1, element2);
|
||||||
if (parent == null) return PsiElement.EMPTY_ARRAY;
|
if (parent == null) return PsiElement.EMPTY_ARRAY;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo() {
|
||||||
|
val a = ""
|
||||||
|
<caret>
|
||||||
|
a
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun foo() {
|
||||||
|
val a = ""
|
||||||
|
|
||||||
|
a
|
||||||
|
}
|
||||||
+6
@@ -43,6 +43,12 @@ public class SurroundWithTestGenerated extends AbstractSurroundWithTest {
|
|||||||
doTestWithIfSurrounder(fileName);
|
doTestWithIfSurrounder(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("emptyLine.kt")
|
||||||
|
public void testEmptyLine() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/surroundWith/if/emptyLine.kt");
|
||||||
|
doTestWithIfSurrounder(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("severalStatements.kt")
|
@TestMetadata("severalStatements.kt")
|
||||||
public void testSeveralStatements() throws Exception {
|
public void testSeveralStatements() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/surroundWith/if/severalStatements.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/surroundWith/if/severalStatements.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user