InsertHandler<LookupElement> (@NotNull TemplateManagerImpl templateManager, @Nullable Template template, @NotNull EventId eventId) { return (context, item) -> { Editor editor = context.getEditor(); if (template != null) { editor.getDocument().deleteString(context.getStartOffset(), context.getTailOffset()); templateManager.startTemplate(editor, template); } else { EditorModificationUtil.insertStringAtCaret(editor, " "); } eventId.log(); }; }