handle broken tail offset after completion (EA-90946 - ISE: OffsetMap.getOffset)
authorpeter <peter@jetbrains.com>
Fri, 4 Nov 2016 14:42:06 +0000 (15:42 +0100)
committerpeter <peter@jetbrains.com>
Fri, 4 Nov 2016 15:01:30 +0000 (16:01 +0100)
platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java

index 17dc588bedf6963010baf2363a7a1f35a65fc693..0ef66ae004831f6264cd4148c7bb15255ffd23a5 100644 (file)
@@ -686,12 +686,11 @@ public class CodeCompletionHandlerBase {
                                         CompletionAssertions.WatchingInsertionContext context,
                                         LookupElement item,
                                         Editor editor, CompletionProgressIndicator indicator, char completionChar) {
-    int tailOffset = context.getTailOffset();
-    if (tailOffset < 0) {
+    if (!context.getOffsetMap().containsOffset(InsertionContext.TAIL_OFFSET)) {
       LOG.info("tailOffset<0 after inserting " + item + " of " + item.getClass() + "; invalidated at: " + context.invalidateTrace + "\n--------");
     }
     else {
-      editor.getCaretModel().moveToOffset(tailOffset);
+      editor.getCaretModel().moveToOffset(context.getTailOffset());
     }
     if (context.getCompletionChar() == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
       final Language language = PsiUtilBase.getLanguageInEditor(editor, project);