diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java index bddf785a2a95..37ee0ab59334 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java @@ -36,7 +36,6 @@ import java.util.List; * @author Gregory.Shrago */ public abstract class BraceMatcherBasedSelectioner extends ExtendWordSelectionHandlerBase { - @Override public List select(final PsiElement e, final CharSequence editorText, final int cursorOffset, final Editor editor) { final VirtualFile file = e.getContainingFile().getVirtualFile(); @@ -60,8 +59,8 @@ public abstract class BraceMatcherBasedSelectioner extends ExtendWordSelectionHa result.addAll(expandToWholeLine(editorText, new TextRange(last.first, iterator.getEnd()))); int bodyStart = last.second; int bodyEnd = iterator.getStart(); - while (bodyStart < textLength && Character.isWhitespace(editorText.charAt(bodyStart))) bodyStart ++; - while (bodyEnd > 0 && Character.isWhitespace(editorText.charAt(bodyEnd - 1))) bodyEnd --; + while (bodyStart < textLength && Character.isWhitespace(editorText.charAt(bodyStart))) bodyStart++; + while (bodyEnd > 0 && bodyStart < bodyEnd && Character.isWhitespace(editorText.charAt(bodyEnd - 1))) bodyEnd--; result.addAll(expandToWholeLine(editorText, new TextRange(bodyStart, bodyEnd))); } iterator.advance(); @@ -69,5 +68,4 @@ public abstract class BraceMatcherBasedSelectioner extends ExtendWordSelectionHa result.add(e.getTextRange()); return result; } - } \ No newline at end of file