From dd14e8b040c6dddf49a1d4bbd6b16836d03e690b Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Fri, 20 Nov 2026 00:42:56 +0800 Subject: [PATCH] fix(run): keep classpath and target probes from opening console windows on Windows (#4562) On Windows the GUI-subsystem app gave console children their own window unless they were spawned with CREATE_NO_WINDOW. Three probes used a bare std Command: the Maven classpath probe behind delegated Run/Debug, the .NET target-path probe and go list for file-scoped Go tests. The first two now go through ide_core::process::prepare; the Go probe, whose environment is already built, gets the flag. The other backend spawn sites already prepare. --- crates/ide-build/src/compile/single.rs | 7 +++---- crates/ide-run/src/dotnet.rs | 2 +- crates/ide-run/src/go.rs | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/ide-build/src/compile/single.rs b/crates/ide-build/src/compile/single.rs index 0625c5a4f..898820200 100644 --- a/crates/ide-build/src/compile/single.rs +++ b/crates/ide-build/src/compile/single.rs @@ -236,10 +236,9 @@ fn classpath( } args.extend(["dependency:build-classpath", output_arg.as_str(), scope_arg.as_str(), "-q"]); let top_dir = subdir(root, &target.top.dir); - let status = ProcCommand::new(&target.top.command) - .args(&args) - .envs(&target.top.env) - .current_dir(&top_dir) + let mut command = ProcCommand::new(&target.top.command); + command.args(&args).envs(&target.top.env).current_dir(&top_dir); + let status = ide_core::process::prepare(&mut command) .output() .map_err(|e| IdeError::internal(format!("cannot resolve the compile classpath: {e}")))?; if !status.status.success() { diff --git a/crates/ide-run/src/dotnet.rs b/crates/ide-run/src/dotnet.rs index 01b5284ad..002ed38e0 100644 --- a/crates/ide-run/src/dotnet.rs +++ b/crates/ide-run/src/dotnet.rs @@ -230,7 +230,7 @@ pub async fn target_path(root: &Path, config: &RunConfig) -> IdeResult { } let mut command = std::process::Command::new(&config.command); command.args(args).current_dir(root); - ide_core::process::host_env(&mut command); + ide_core::process::prepare(&mut command); if !config.extras.include_system_env { command.env_clear(); } else { diff --git a/crates/ide-run/src/go.rs b/crates/ide-run/src/go.rs index 2d9b260cc..d714e0764 100644 --- a/crates/ide-run/src/go.rs +++ b/crates/ide-run/src/go.rs @@ -124,6 +124,11 @@ fn package_info(mut command: Command, dir: &Path, flags: &[String]) -> IdeResult } } command.arg(".").current_dir(dir).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped()); + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + command.creation_flags(ide_core::process::CREATE_NO_WINDOW); + } let mut child = command.spawn()?; let stdout = child.stdout.take(); let stderr = child.stderr.take();