void (@NotNull InsertionContext context, @NotNull LookupElement item) { ApplicationManager.getApplication().assertWriteAccessAllowed(); Editor editor = context.getEditor(); Project project = context.getProject(); if (handleInsideQuotesInsertion(context, editor, hasValue)) return; int offset = editor.getCaretModel().getOffset(); int initialOffset = offset; CharSequence docChars = context.getDocument().getCharsSequence(); while (offset < docChars.length() && Character.isWhitespace(docChars.charAt(offset))) { offset++; } if (hasValue) { // fix colon for YAML and alike if (offset < docChars.length() && docChars.charAt(offset) != ':') { editor.getDocument().insertString(initialOffset, ":"); handleWhitespaceAfterColon(editor, docChars, initialOffset + 1); } return; } if (offset < docChars.length() && docChars.charAt(offset) == ':') { handleWhitespaceAfterColon(editor, docChars, offset + 1); } else { // inserting longer string for proper formatting final String stringToInsert = ": 1" + (insertComma ? "," : ""); EditorModificationUtil.insertStringAtCaret(editor, stringToInsert, false, true, 2); formatInsertedString(context, stringToInsert.length()); offset = editor.getCaretModel().getOffset(); context.getDocument().deleteString(offset, offset + 1); } PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); AutoPopupController.getInstance(context.getProject()).autoPopupMemberLookup(context.getEditor(), null); }