@Override
    protected void executeInLookup(LookupImpl lookup, DataContext context, final Caret caret) {
      final Editor editor = lookup.getEditor();
      final int offset = editor.getCaretModel().getOffset();
      final CharSequence seq = editor.getDocument().getCharsSequence();
      if (seq.length() <= offset || !lookup.isCompletion()) {
        myOriginalHandler.execute(editor, caret, context);
        return;
      }

      char c = seq.charAt(offset);
      CharFilter.Result lookupAction = LookupTypedHandler.getLookupAction(c, lookup);

      if (lookupAction != CharFilter.Result.ADD_TO_PREFIX || Character.isWhitespace(c)) {
        myOriginalHandler.execute(editor, caret, context);
        return;
      }

      if (!lookup.performGuardedChange(() -> {
        CaretAction action = lookupCaret -> {
          lookupCaret.removeSelection();
          int caretOffset = lookupCaret.getOffset();
          if (caretOffset < seq.length()) {
            lookupCaret.moveToOffset(caretOffset + 1);
          }
        };
        if (caret == null) {
          editor.getCaretModel().runForEachCaret(action);
        }
        else {
          action.perform(caret);
        }
      })) {
        return;
      }

      lookup.fireBeforeAppendPrefix(c);
      lookup.appendPrefix(c);
      final CompletionProgressIndicator completion = CompletionServiceImpl.getCurrentCompletionProgressIndicator();
      if (completion != null) {
        completion.prefixUpdated();
      }
    }
@Override
    protected void executeInLookup(LookupImpl lookup, DataContext context, final Caret caret)