void (char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!(c == ' ' && file instanceof YAMLFile)) { return; } if (!file.isValid()) { return; } int curPosOffset = editor.getCaretModel().getOffset(); if (curPosOffset < 2) { return; } int offset = curPosOffset - 2; Document document = editor.getDocument(); if (document.getCharsSequence().charAt(offset) != '-') { return; } if (curPosOffset < document.getTextLength() && document.getCharsSequence().charAt(curPosOffset) != '\n') { return; } PsiDocumentManager.getInstance(project).commitDocument(document); PsiElement element = file.findElementAt(offset); if (PsiUtilCore.getElementType(element) != YAMLTokenTypes.SEQUENCE_MARKER) { return; } PsiElement item = element.getParent(); if (PsiUtilCore.getElementType(item) != YAMLElementTypes.SEQUENCE_ITEM) { // Should not be possible now return; } PsiElement sequence = item.getParent(); if (PsiUtilCore.getElementType(sequence) != YAMLElementTypes.SEQUENCE) { // It could be some composite component (with syntax error) return; } if (((YAMLSequence)sequence).getItems().size() != 1) { return; } DefaultRawTypedHandler handler = ((TypedActionImpl)TypedAction.getInstance()).getDefaultRawTypedHandler(); handler.beginUndoablePostProcessing(); ApplicationManager.getApplication().runWriteAction(() -> { int newOffset = CodeStyleManager.getInstance(project).adjustLineIndent(file, offset); editor.getCaretModel().moveToOffset(newOffset + 2); }); }