From c8a4b34bd2085fd7a62b4616ef1fa964d2f6491d Mon Sep 17 00:00:00 2001 From: Alexey Katsman Date: Wed, 5 Nov 2025 14:37:04 +0100 Subject: [PATCH] PY-84969 Make sure sdkAdded callback is called for remote interpreters After changing dialogs for creating remote SDKs we ended up in a situation when we've already persisted our SDK (see commonKt#setupSdk). That leads to a situation when we're not calling our sdkCreated callback in exitHandler of TargetEnvironmentWizard (see AddInterpreterActions). There is a check for existing SDK (and it was already persisted), and only if SDK doesn't exist we execute the callback. And if we don't invoke that callback, we're also not getting to the jdkAdded call in PythonSdkTableListener, which in the end leads to a missing SDK entry in IDEA after creation (it only appears after reopening Project Structure). The fix is to move the sdkCreated callback out of the condition, however we don't really need the calls to addSdk and apply since we do addSdk inside the callback anyway and it's not necessary to call apply since it only affects the changelog of sdks for Apply button in Project Structure. GitOrigin-RevId: 0c87588c4f87bc9888993d845b0c8588b27e104d --- .../src/com/jetbrains/python/sdk/AddInterpreterActions.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python/src/com/jetbrains/python/sdk/AddInterpreterActions.kt b/python/src/com/jetbrains/python/sdk/AddInterpreterActions.kt index 5fb5d77cdd52..a2d053aa2f57 100644 --- a/python/src/com/jetbrains/python/sdk/AddInterpreterActions.kt +++ b/python/src/com/jetbrains/python/sdk/AddInterpreterActions.kt @@ -22,7 +22,6 @@ import com.intellij.openapi.ui.DialogWrapper.OK_EXIT_CODE import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.NlsActions import com.jetbrains.python.PyBundle -import com.jetbrains.python.configuration.PyConfigurableInterpreterList import com.jetbrains.python.run.PythonInterpreterTargetEnvironmentFactory import com.jetbrains.python.run.allowCreationTargetOfThisType import com.jetbrains.python.sdk.ModuleOrProject.ModuleAndProject @@ -131,15 +130,10 @@ private class AddInterpreterOnTargetAction( private fun exitHandler(dialogWrapper: TargetEnvironmentWizard) { if (dialogWrapper.exitCode != OK_EXIT_CODE) return - val model = PyConfigurableInterpreterList.getInstance(project).model val sdk = (dialogWrapper.currentStepObject as? TargetCustomToolWizardStep)?.customTool as? Sdk ?: return PythonNewInterpreterAddedCollector.logPythonNewInterpreterAdded(sdk, isPreviouslyConfigured = true) - if (model.findSdk(sdk.name) == null) { - model.addSdk(sdk) - model.apply() - onSdkCreated.accept(sdk) - } + onSdkCreated.accept(sdk) } }