Skip to content

Commit 047f997

Browse files
committed
fix (core): 修复指定目录后执行命令位置问题
1 parent e0cda52 commit 047f997

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src-tauri/src/plugins/mod.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)