From 6335103904ee0f85983143b52d66e080d6bb0896 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. (cherry picked from commit 56ec8af1889117503d19aeae9c95fe3f930de95d) IJ-MR-181485 GitOrigin-RevId: feec34e57b7c6a9df13e4158c53593f1b8d6f1f1 --- .../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) } }