From 461812d7b6de0064e2bffd224f82a95351d0f1cb Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Fri, 13 Sep 2024 04:15:20 +0800 Subject: [PATCH] windows: Use the existing `open_target` function for `platform::open_with_system` (#17705) Release Notes: - N/A --- crates/gpui/src/platform/windows/platform.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index f8b3924e6282b1339a5bf43276efa48e25d26fe5..934d9336d2f6c234801c456888167636b8bc3fc4 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -401,14 +401,19 @@ impl Platform for WindowsPlatform { } fn open_with_system(&self, path: &Path) { - let executor = self.background_executor().clone(); - let path = path.to_owned(); - executor + let Ok(full_path) = path.canonicalize() else { + log::error!("unable to parse file full path: {}", path.display()); + return; + }; + self.background_executor() .spawn(async move { - let _ = std::process::Command::new("cmd") - .args(&["/c", "start", "", path.to_str().expect("path to string")]) - .spawn() - .expect("Failed to open file"); + let Some(full_path_str) = full_path.to_str() else { + return; + }; + if full_path_str.is_empty() { + return; + }; + open_target(full_path_str); }) .detach(); }