File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,15 +77,32 @@ pub trait LanguagePlugin: Send + Sync {
7777 fn get_command ( & self , file_path : Option < & str > ) -> String {
7878 if let Some ( config) = self . get_config ( ) {
7979 if let Some ( run_cmd) = & config. run_command {
80- if let Some ( path) = file_path {
81- return run_cmd. replace ( "$filename" , path) ;
80+ return if let Some ( path) = file_path {
81+ let final_cmd = if self . get_execute_home ( ) . is_some ( ) {
82+ // 如果有执行主目录,在整个命令前面加 ./
83+ let cmd_with_file = run_cmd. replace ( "$filename" , path) ;
84+ if cmd_with_file. starts_with ( "./" ) {
85+ cmd_with_file
86+ } else {
87+ format ! ( "./{}" , cmd_with_file)
88+ }
89+ } else {
90+ run_cmd. replace ( "$filename" , path)
91+ } ;
92+ final_cmd
8293 } else {
83- return run_cmd
94+ let base_cmd = run_cmd
8495 . split_whitespace ( )
8596 . next ( )
8697 . unwrap_or ( & config. language )
8798 . to_string ( ) ;
88- }
99+
100+ if self . get_execute_home ( ) . is_some ( ) && !base_cmd. starts_with ( "./" ) {
101+ format ! ( "./{}" , base_cmd)
102+ } else {
103+ base_cmd
104+ }
105+ } ;
89106 }
90107 }
91108 self . get_default_command ( )
You can’t perform that action at this time.
0 commit comments