diff --git a/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt b/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt index ff101f224cc1..52db4af90e4b 100644 --- a/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt +++ b/plugins/markdown/src/org/intellij/plugins/markdown/fileActions/export/MarkdownExportDialog.kt @@ -52,7 +52,7 @@ internal class MarkdownExportDialog( val fileTypeProperty = PropertyGraph().graphProperty { selectedFileType } fileTypeProperty.afterChange { selectedFileType = it } - selectedFileType = supportedExportProviders.first() + selectedFileType = findFirstValidProvider() ?: supportedExportProviders.first() label(MarkdownBundle.message("markdown.export.dialog.filetype.label")) fileTypeSelector = comboBox(model, fileTypeProperty, FileTypeRenderer()) .withValidationOnApply { validateFileType(it) } @@ -73,6 +73,9 @@ internal class MarkdownExportDialog( return panel } + private fun findFirstValidProvider(): MarkdownExportProvider? = + supportedExportProviders.find { it.validate(project, targetFile) == null } + private fun JComponent.visible(predicate: ComponentPredicate) { isVisible = predicate() predicate.addListener { isVisible = it } @@ -100,7 +103,8 @@ internal class MarkdownExportDialog( if (errorMessage != null) { isEnabled = false toolTipText = errorMessage - } else { + } + else { isEnabled = true } }