void (@NotNull InsertionContext context, @NotNull LookupElement item) { if (context.getCompletionChar() != Lookup.REPLACE_SELECT_CHAR) { return; } String lookupString = item.getLookupString(); Document doc = context.getDocument(); int tailOffset = context.getTailOffset(); if (lookupString.endsWith("=") && CharArrayUtil.regionMatches(doc.getCharsSequence(), tailOffset, "=")) { doc.deleteString(tailOffset, tailOffset + 1); } else if (lookupString.endsWith(" = ") && CharArrayUtil.regionMatches(doc.getCharsSequence(), tailOffset, " = ")) { doc.deleteString(tailOffset, tailOffset + 3); } }