@@ -7,6 +7,24 @@ use tauri::{command, Manager};
77use tauri_plugin_window_state:: { AppHandleExt , WindowExt , StateFlags } ;
88use tokio:: process:: Command ;
99
10+ fn create_hidden_command ( program : & str ) -> Command {
11+ #[ cfg( target_os = "windows" ) ]
12+ {
13+ use std:: os:: windows:: process:: CommandExt ;
14+ let mut std_cmd = std:: process:: Command :: new ( program) ;
15+ const CREATE_NO_WINDOW : u32 = 0x08000000 ;
16+ std_cmd. creation_flags ( CREATE_NO_WINDOW ) ;
17+
18+ // Convert std::process::Command to tokio::process::Command
19+ Command :: from ( std_cmd)
20+ }
21+
22+ #[ cfg( not( target_os = "windows" ) ) ]
23+ {
24+ Command :: new ( program)
25+ }
26+ }
27+
1028#[ derive( Debug , Serialize , Deserialize ) ]
1129pub struct GitHunk {
1230 file_name : String ,
@@ -53,7 +71,7 @@ pub struct GitRefs {
5371}
5472
5573async fn check_editor_available ( cmd : & str , args : & [ & str ] ) -> bool {
56- Command :: new ( cmd)
74+ create_hidden_command ( cmd)
5775 . args ( args)
5876 . stdout ( Stdio :: piped ( ) )
5977 . stderr ( Stdio :: piped ( ) )
@@ -107,11 +125,11 @@ async fn find_available_editor() -> Result<&'static str, String> {
107125
108126fn build_editor_command ( editor : & str , file_path : & str , line_number : Option < u32 > ) -> Command {
109127 let mut command = if editor == "cmd-code" {
110- let mut c = Command :: new ( "cmd" ) ;
128+ let mut c = create_hidden_command ( "cmd" ) ;
111129 c. arg ( "/c" ) . arg ( "code" ) . arg ( "-r" ) ;
112130 c
113131 } else {
114- Command :: new ( editor)
132+ create_hidden_command ( editor)
115133 } ;
116134
117135 match editor {
@@ -148,7 +166,7 @@ fn build_editor_command(editor: &str, file_path: &str, line_number: Option<u32>)
148166}
149167
150168async fn run_git_command ( args : & [ & str ] , directory : & str ) -> Result < String , String > {
151- let output = Command :: new ( "git" )
169+ let output = create_hidden_command ( "git" )
152170 . args ( args)
153171 . current_dir ( directory)
154172 . stdout ( Stdio :: piped ( ) )
@@ -331,7 +349,7 @@ async fn get_git_diff(
331349
332350 // git diff --no-index returns exit code 1 when files differ, which is expected
333351 // So we need to handle this manually instead of using run_git_command_optional
334- let untracked_diff = Command :: new ( "git" )
352+ let untracked_diff = create_hidden_command ( "git" )
335353 . args ( & [
336354 "diff" ,
337355 "--no-index" ,
0 commit comments