The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
fix(process): Spawn child processes without a console window (#17)
@鹿a765959d48e9
diff --git a/crates/ide-build/src/process.rs b/crates/ide-build/src/process.rsindex c1e1eb41a..1e129fd3a 100644--- a/crates/ide-build/src/process.rs+++ b/crates/ide-build/src/process.rs@@ -52,12 +52,7 @@ pub(crate) fn run(use std::os::unix::process::CommandExt;command.process_group(0);}- #[cfg(windows)]- {- use std::os::windows::process::CommandExt;- const CREATE_NO_WINDOW: u32 = 0x0800_0000;- command.creation_flags(CREATE_NO_WINDOW);- }+ ide_core::process::no_window(&mut command);let mut child = command.spawn().map_err(|e| IdeError::unavailable(format!("cannot start {program}: {e}")))?;let (tx, rx) = mpsc::channel::<(Stream, String)>();let pump = |stream: Box<dyn Read + Send>, kind: Stream, tx: mpsc::Sender<(Stream, String)>| {diff --git a/crates/ide-core/src/process.rs b/crates/ide-core/src/process.rsindex bcfbadb82..78182623d 100644--- a/crates/ide-core/src/process.rs+++ b/crates/ide-core/src/process.rs@@ -2,6 +2,10 @@use std::process::Command;+/// Windows `CREATE_NO_WINDOW` creation flag, for call sites that combine it+/// with other flags. Prefer [`no_window`] otherwise.+pub const CREATE_NO_WINDOW: u32 = 0x0800_0000;+/// Keeps a console child (java, node, curl, a language server, ...) from/// opening its own console window on Windows. Release builds use the GUI/// subsystem, so without this every spawn flashes a `cmd` window. A no-op@@ -10,7 +14,6 @@ pub fn no_window(cmd: &mut Command) -> &mut Command {#[cfg(windows)]{use std::os::windows::process::CommandExt;- const CREATE_NO_WINDOW: u32 = 0x0800_0000;cmd.creation_flags(CREATE_NO_WINDOW);}cmddiff --git a/crates/ide-docker/src/process.rs b/crates/ide-docker/src/process.rsindex 76870106b..f0c47f044 100644--- a/crates/ide-docker/src/process.rs+++ b/crates/ide-docker/src/process.rs@@ -25,11 +25,7 @@ fn prepare(cmd: &mut Command) {use std::os::unix::process::CommandExt;cmd.process_group(0);}- #[cfg(windows)]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x0800_0000);- }+ ide_core::process::no_window(cmd);}fn spawn(cmd: &mut Command) -> IdeResult<Child> {diff --git a/crates/ide-github/src/process.rs b/crates/ide-github/src/process.rsindex 63aae7e79..4a574fcbc 100644--- a/crates/ide-github/src/process.rs+++ b/crates/ide-github/src/process.rs@@ -25,11 +25,7 @@ fn prepare(cmd: &mut Command) {use std::os::unix::process::CommandExt;cmd.process_group(0);}- #[cfg(windows)]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x0800_0000);- }+ ide_core::process::no_window(cmd);}fn spawn(cmd: &mut Command) -> IdeResult<Child> {diff --git a/crates/ide-run/src/process.rs b/crates/ide-run/src/process.rsindex 4b25f99cb..93c5b9495 100644--- a/crates/ide-run/src/process.rs+++ b/crates/ide-run/src/process.rs@@ -205,8 +205,7 @@ impl ProcessManager {{use std::os::windows::process::CommandExt;const CREATE_NEW_PROCESS_GROUP: u32 = 0x0000_0200;- const CREATE_NO_WINDOW: u32 = 0x0800_0000;- cmd.creation_flags(CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW);+ cmd.creation_flags(CREATE_NEW_PROCESS_GROUP | ide_core::process::CREATE_NO_WINDOW);}let mut child = cmd.spawn().map_err(|e| match e.kind() {@@ -400,7 +399,7 @@ fn kill_tree(pid: u32, _force: bool) {// Console children have no reliable graceful signal from outside their console.let _ = Command::new("taskkill").args(["/T", "/F", "/PID", &pid.to_string()])- .creation_flags(0x0800_0000)+ .creation_flags(ide_core::process::CREATE_NO_WINDOW).stdout(Stdio::null()).stderr(Stdio::null()).status();diff --git a/crates/ide-vcs/src/cli.rs b/crates/ide-vcs/src/cli.rsindex b69ddd029..97f687c63 100644--- a/crates/ide-vcs/src/cli.rs+++ b/crates/ide-vcs/src/cli.rs@@ -64,11 +64,7 @@ pub fn git_version(executable: Option<&Path>) -> IdeResult<String> {};let mut cmd = Command::new(&exe);cmd.arg("--version").stdin(Stdio::null()).env("LC_ALL", "C");- #[cfg(windows)]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x0800_0000);- }+ ide_core::process::no_window(&mut cmd);let out = cmd.output().map_err(|e| IdeError::unavailable(format!("cannot run {}: {e}", exe.display())))?;let text = String::from_utf8_lossy(&out.stdout).trim().to_string();if !out.status.success() || !text.starts_with("git version") {@@ -99,12 +95,7 @@ pub(crate) fn command(root: &Path) -> IdeResult<Command> {.env_remove("GIT_DIR").env_remove("GIT_WORK_TREE").env_remove("GIT_INDEX_FILE");- #[cfg(windows)]- {- use std::os::windows::process::CommandExt;- const CREATE_NO_WINDOW: u32 = 0x0800_0000;- cmd.creation_flags(CREATE_NO_WINDOW);- }+ ide_core::process::no_window(&mut cmd);Ok(cmd)}