From c9d10910e4c6b26950f9a0e42529df1be7d47083 Mon Sep 17 00:00:00 2001 From: MissterHao Date: Tue, 29 Nov 2022 15:42:37 +0800 Subject: [PATCH] fix: use different cmd tool in different os --- src/application/app.rs | 52 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/application/app.rs b/src/application/app.rs index c6afeec..b96fb92 100644 --- a/src/application/app.rs +++ b/src/application/app.rs @@ -160,43 +160,35 @@ impl<'a> App<'a> { /// Open workspace by vscode #[cfg(target_os = "windows")] fn open_workspace(&mut self) { - match self.select_workspace() { - Some(workspace) => { - if workspace.location_type - == crate::domain::entity::workspace::WorkspaceLocation::Local - { - // Use cmd as program instead - // https://github.com/rust-lang/rust/issues/95957 - Command::new("cmd") - .arg("/C") - .arg("code") - .arg(workspace.strip_decode_path()) - .spawn() - .expect("code command failed to start"); - } + if let Some(workspace) = self.select_workspace() { + if workspace.location_type == crate::domain::entity::workspace::WorkspaceLocation::Local + { + // Use cmd as program instead + // https://github.com/rust-lang/rust/issues/95957 + Command::new("cmd") + .arg("/C") + .arg("code") + .arg(workspace.strip_decode_path()) + .spawn() + .expect("code command failed to start"); } - None => {} } } #[cfg(target_os = "linux")] fn open_workspace(&mut self) { - match self.select_workspace() { - Some(workspace) => { - if workspace.location_type - == crate::domain::entity::workspace::WorkspaceLocation::Local - { - // Use cmd as program instead - // https://github.com/rust-lang/rust/issues/95957 - Command::new("bash") - .arg("-c") - .arg("code") - .arg(workspace.strip_decode_path()) - .spawn() - .expect("code command failed to start"); - } + if let Some(workspace) = self.select_workspace() { + if workspace.location_type == crate::domain::entity::workspace::WorkspaceLocation::Local + { + // Use cmd as program instead + // https://github.com/rust-lang/rust/issues/95957 + Command::new("bash") + .arg("-c") + .arg("code") + .arg(workspace.strip_decode_path()) + .spawn() + .expect("code command failed to start"); } - None => {} } }