windows: Prevent command line from opening in release mode (#9839)
Release Notes: - Prevents the terminal from opening on release mode on Windows Note: this also prevents Zed from logging to the terminal when it is launched from the terminal. Is this expected behaviour on other platforms? --------- Co-authored-by: 白山風露 <shirayama.kazatsuyu@gmail.com>
This commit is contained in:
parent
95699a07f4
commit
3046ef6471
4 changed files with 16 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5570,6 +5570,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smol",
|
"smol",
|
||||||
"util",
|
"util",
|
||||||
|
"windows 0.53.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -31,6 +31,9 @@ smol.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
release_channel.workspace = true
|
release_channel.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
windows.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "82d00a04211cf4e1236029aa03e6b6ce2a74c553" }
|
async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "82d00a04211cf4e1236029aa03e6b6ce2a74c553" }
|
||||||
ctor.workspace = true
|
ctor.workspace = true
|
||||||
|
|
|
@ -15,6 +15,10 @@ use smol::{
|
||||||
io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader},
|
io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader},
|
||||||
process::{self, Child},
|
process::{self, Child},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use smol::process::windows::CommandExt;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
fmt,
|
fmt,
|
||||||
|
@ -215,15 +219,18 @@ impl LanguageServer {
|
||||||
&binary.arguments
|
&binary.arguments
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut server = process::Command::new(&binary.path)
|
let mut command = process::Command::new(&binary.path);
|
||||||
|
command
|
||||||
.current_dir(working_dir)
|
.current_dir(working_dir)
|
||||||
.args(binary.arguments)
|
.args(binary.arguments)
|
||||||
.envs(binary.env.unwrap_or_default())
|
.envs(binary.env.unwrap_or_default())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.kill_on_drop(true)
|
.kill_on_drop(true);
|
||||||
.spawn()?;
|
#[cfg(windows)]
|
||||||
|
command.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW.0);
|
||||||
|
let mut server = command.spawn()?;
|
||||||
|
|
||||||
let stdin = server.stdin.take().unwrap();
|
let stdin = server.stdin.take().unwrap();
|
||||||
let stdout = server.stdout.take().unwrap();
|
let stdout = server.stdout.take().unwrap();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// Allow binary to be called Zed for a nice application menu when running executable directly
|
// Allow binary to be called Zed for a nice application menu when running executable directly
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
// Disable command line from opening on release mode
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
mod zed;
|
mod zed;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue