void (@NotNull AnActionEvent event) { final var editor = MarkdownActionUtil.findMarkdownEditor(event); final var psiFile = event.getData(CommonDataKeys.PSI_FILE); if (editor == null || psiFile == null || !psiFile.isValid()) { return; } final var carets = SelectionUtil.obtainCaretSnapshots(this, event); if (carets == null) { event.getPresentation().setEnabled(false); return; } for (final var caret: carets) { if (!isEnabledForCaret(psiFile, caret.getSelectionStart(), caret.getSelectionEnd())) { event.getPresentation().setEnabled(false); return; } } event.getPresentation().setEnabled(true); }