LiteralSelectioner: do not include spaces before first line break in expand selection for text block (IDEA-CR-52334)

GitOrigin-RevId: af2f4af25da50b8b22d0d8f538ee6cf87b550be1
This commit is contained in:
Artemiy Sartakov
2019-10-02 11:32:52 +00:00
committed by intellij-monorepo-bot
parent cddc167959
commit bde6e85c9c
@@ -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));