Repository: lapce/lapce (language: rust)

Issue:
Windows Terminal opens when launching Lapce
## Lapce Version

0.4.2

## System information

Windows 11 23H2

## Describe the bug

Windows Terminal is launched every time I launch Lapce:

1. I open Lapce through the start menu.
2. Windows Terminal launches.
3. It contains a tab with what looks like the Windows Powershell icon, and it closes almost immediately.
4. Windows Terminal is left open with a tab from my default Git Bash shell.
5. Lapce launches

## Additional information

I have seen similar behaviour with flashing Windows Terminal when using the terminal in Zed on Windows, so I'd put my money on it being alacritty-related. But this is more or less just a guess.



Discussion / hints:
I have reproduced this in windows 11 24H2. The terminal open and closes twice.
Reproduced this with Lapce 0.4.2 installed via [Scoop](https://scoop.sh/) on Windows 10 22H2 : two terminals open and both stay open .
I have to close them manually.
Adding the `CREATE_NO_WINDOW` flag should help.
https://github.com/lapce/lapce/blob/3a40e6b729530ac176b55b426715dacc22f1c791/lapce-app/src/app.rs#L3994-L4003
https://github.com/lapce/lapce/blob/3a40e6b729530ac176b55b426715dacc22f1c791/lapce-app/src/app.rs#L3706-L3707

But I don't quite understand why we need to load envs from the shell?

Fix patch:
diff --git a/lapce-app/src/app.rs b/lapce-app/src/app.rs
index 2a7ea55530..d1562ff820 100644
--- a/lapce-app/src/app.rs
+++ b/lapce-app/src/app.rs
@@ -3704,7 +3704,7 @@ pub fn launch() {
         args.push("--wait".to_string());
         let mut cmd = std::process::Command::new(&args[0]);
         #[cfg(target_os = "windows")]
-        cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
+        cmd.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW);
 
         let stderr_file_path =
             Directory::logs_directory().unwrap().join("stderr.log");
@@ -4002,6 +4002,9 @@ pub fn load_shell_env() {
         "Get-ChildItem env: | ForEach-Object { \"{0}={1}\" -f $_.Name, $_.Value }",
     ]);
 
+    #[cfg(windows)]
+    command.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW);
+
     let env = match command.output() {
         Ok(output) => String::from_utf8(output.stdout).unwrap_or_default(),
 


Test patch: