Result (@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final DataContext dataContext) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return Result.Continue; } if (!file.getViewProvider().getLanguages().contains(myLanguage)) { return Result.Continue; } if (editor.isViewer()) { return Result.Continue; } final Document document = editor.getDocument(); if (!document.isWritable()) { return Result.Continue; } PsiDocumentManager.getInstance(project).commitDocument(document); int caret = editor.getCaretModel().getOffset(); if (caret == 0) { return Result.DefaultSkipIndent; } if (caret <= 0) { return Result.Continue; } return null; }