diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java index 7c3f5738a74b..9026286d2778 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actions.EditorActionUtil; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.TextRange; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; @@ -259,10 +260,7 @@ public class SelectWordUtil { } long stamp = editor.getDocument().getModificationStamp(); for (ExtendWordSelectionHandler selectioner : availableSelectioners) { - List ranges = selectioner.select(element, text, cursorOffset, editor); - if (stamp != editor.getDocument().getModificationStamp()) { - throw new AssertionError("Selectioner " + selectioner + " has changed the document"); - } + List ranges = askSelectioner(element, text, cursorOffset, editor, stamp, selectioner); if (ranges == null) continue; for (TextRange range : ranges) { @@ -275,6 +273,25 @@ public class SelectWordUtil { return stop; } + @Nullable + private static List askSelectioner(@NotNull PsiElement element, + CharSequence text, + int cursorOffset, + Editor editor, + long stamp, + ExtendWordSelectionHandler selectioner) { + try { + List ranges = selectioner.select(element, text, cursorOffset, editor); + if (stamp != editor.getDocument().getModificationStamp()) { + throw new AssertionError("Selectioner " + selectioner + " has changed the document"); + } + return ranges; + } + catch (IndexNotReadyException e) { + return null; + } + } + public static void addWordHonoringEscapeSequences(CharSequence editorText, TextRange literalTextRange, int cursorOffset,