From c591745db3cdb45228ac8b4945ef69499682c533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Smolarek?= <34063647+Razz4780@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:21:23 +0100 Subject: [PATCH] Fix targetless selection (#200) * Fixed selecting targetless option in the dialog * Changelog entry * Update changelog.d/+targetless-selection.fixed.md Co-authored-by: t4lz --------- Co-authored-by: t4lz --- changelog.d/+targetless-selection.fixed.md | 1 + .../kotlin/com/metalbear/mirrord/MirrordExecManager.kt | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog.d/+targetless-selection.fixed.md diff --git a/changelog.d/+targetless-selection.fixed.md b/changelog.d/+targetless-selection.fixed.md new file mode 100644 index 00000000..122d524e --- /dev/null +++ b/changelog.d/+targetless-selection.fixed.md @@ -0,0 +1 @@ +Fixed a bug with selecting `targetless` option from the target selection dialog. \ No newline at end of file diff --git a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt index af7fbec0..4be92d19 100644 --- a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt +++ b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.components.service import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.util.alsoIfNull import java.nio.file.Path /** @@ -135,8 +136,9 @@ class MirrordExecManager(private val service: MirrordProjectService) { val target = if (!targetSet) { // There is no config file or the config does not specify a target, so show dialog. MirrordLogger.logger.debug("target not selected, showing dialog") - chooseTarget(cli, wslDistribution, configPath).also { - if (it == MirrordExecDialog.targetlessTargetName) { + chooseTarget(cli, wslDistribution, configPath) + .takeUnless { it == MirrordExecDialog.targetlessTargetName } + .alsoIfNull { MirrordLogger.logger.info("No target specified - running targetless") service.notifier.notification( "No target specified, mirrord running targetless.", @@ -145,7 +147,6 @@ class MirrordExecManager(private val service: MirrordProjectService) { .withDontShowAgain(MirrordSettingsState.NotificationId.RUNNING_TARGETLESS) .fire() } - } } else { null }