diff --git a/exts/ext-http-client/src/main/kotlin/cc/unitmesh/httpclient/IntellijHttpClientExecutor.kt b/exts/ext-http-client/src/main/kotlin/cc/unitmesh/httpclient/IntellijHttpClientExecutor.kt index c6e36143b..3b47beade 100644 --- a/exts/ext-http-client/src/main/kotlin/cc/unitmesh/httpclient/IntellijHttpClientExecutor.kt +++ b/exts/ext-http-client/src/main/kotlin/cc/unitmesh/httpclient/IntellijHttpClientExecutor.kt @@ -2,11 +2,13 @@ package cc.unitmesh.httpclient import cc.unitmesh.devti.provider.http.HttpClientProvider import com.intellij.execution.Executor +import com.intellij.execution.RunManager import com.intellij.execution.RunnerAndConfigurationSettings import com.intellij.execution.actions.ConfigurationContext import com.intellij.httpClient.http.request.run.HttpRequestExecutorExtensionFactory import com.intellij.httpClient.http.request.run.HttpRequestRunConfigurationExecutor import com.intellij.httpClient.http.request.run.config.HttpRequestRunConfiguration +import com.intellij.httpClient.http.request.run.config.HttpRequestRunConfigurationType import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiFile @@ -21,9 +23,20 @@ class IntellijHttpClientExecutor : HttpClientProvider { ?.firstOrNull() ?.configurationSettings ?: return -// runner.configuration?.apply { -// this as HttpRequestRunConfiguration -// } + + val factory = HttpRequestRunConfigurationType.getInstance().configurationFactories[0] + val configuration = HttpRequestRunConfiguration(project, factory, "HttpRequest") + + val runManager: RunManager = RunManager.getInstance(project) + runManager.setUniqueNameIfNeeded(configuration) + runManager.addConfiguration(runner) + + runner.isTemporary = true + + val selectedRunner = runManager.selectedConfiguration + if ((selectedRunner == null || selectedRunner.isTemporary) && runManager.shouldSetRunConfigurationFromContext()) { + runManager.selectedConfiguration = runner + } val executor: Executor = HttpRequestExecutorExtensionFactory.getRunExtension().executor ?: return HttpRequestRunConfigurationExecutor.getInstance().execute(