mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 03:09:06 +03:00
windows: gui: only attach parent console when spawned by wezterm
speculative attempt to do something about https://github.com/wez/wezterm/issues/1278
This commit is contained in:
parent
a006f9a119
commit
3b30230d58
@ -72,6 +72,11 @@ struct Opt {
|
||||
number_of_values = 1)]
|
||||
config_override: Vec<(String, String)>,
|
||||
|
||||
/// On Windows, whether to attempt to attach to the parent
|
||||
/// process console to display logging output
|
||||
#[structopt(long = "attach-parent-console")]
|
||||
attach_parent_console: bool,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
cmd: Option<SubCommand>,
|
||||
}
|
||||
@ -585,6 +590,8 @@ fn run() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let opts = Opt::from_args();
|
||||
|
||||
// This is a bit gross.
|
||||
// In order to not to automatically open a standard windows console when
|
||||
// we run, we use the windows_subsystem attribute at the top of this
|
||||
@ -598,7 +605,9 @@ fn run() -> anyhow::Result<()> {
|
||||
// input but didn't know to re-draw the prompt.
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
winapi::um::wincon::AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS);
|
||||
if opts.attach_parent_console {
|
||||
winapi::um::wincon::AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS);
|
||||
}
|
||||
};
|
||||
|
||||
env_bootstrap::bootstrap();
|
||||
@ -606,7 +615,6 @@ fn run() -> anyhow::Result<()> {
|
||||
stats::Stats::init()?;
|
||||
let _saver = umask::UmaskSaver::new();
|
||||
|
||||
let opts = Opt::from_args();
|
||||
config::common_init(
|
||||
opts.config_file.as_ref(),
|
||||
&opts.config_override,
|
||||
|
@ -342,6 +342,10 @@ fn delegate_to_gui(saver: UmaskSaver) -> anyhow::Result<()> {
|
||||
let mut cmd = Command::new(exe);
|
||||
cmd.args(std::env::args_os().skip(1));
|
||||
|
||||
if cfg!(windows) {
|
||||
cmd.arg("--attach-parent-console");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::process::CommandExt;
|
||||
|
Loading…
Reference in New Issue
Block a user