From bde6e85c9c043a1e4e4cc99ab3c237a7e10bfbe4 Mon Sep 17 00:00:00 2001 From: Artemiy Sartakov Date: Wed, 2 Oct 2019 18:21:14 +0700 Subject: [PATCH] LiteralSelectioner: do not include spaces before first line break in expand selection for text block (IDEA-CR-52334) GitOrigin-RevId: af2f4af25da50b8b22d0d8f538ee6cf87b550be1 --- .../editorActions/wordSelection/LiteralSelectioner.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java index ab408e7e3151..6bcd44ca5e59 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/LiteralSelectioner.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.editorActions.SelectWordUtil; import com.intellij.lexer.StringLiteralLexer; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLiteralExpression; @@ -58,7 +59,9 @@ public class LiteralSelectioner extends BasicSelectioner { PsiLiteralExpressionImpl literalExpression = tryCast(e, PsiLiteralExpressionImpl.class); if (literalExpression == null) literalExpression = tryCast(e.getParent(), PsiLiteralExpressionImpl.class); if (literalExpression != null && literalExpression.getLiteralElementType() == JavaTokenType.TEXT_BLOCK_LITERAL) { - result.add(new TextRange(range.getStartOffset() + 3, range.getEndOffset() - 3)); + int start = StringUtil.indexOf(editorText, '\n', range.getStartOffset()) + 1; + int end = range.getEndOffset() - 3; + if (start < end) result.add(new TextRange(start, end)); } else { result.add(new TextRange(range.getStartOffset() + 1, range.getEndOffset() - 1));