diff --git a/src/commands.rs b/src/commands.rs index 15d08dbab..9f6da7a1b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -2375,10 +2375,8 @@ fn edit_description( .config() .get("ui.editor") .unwrap_or_else(|_| "pico".into()); - let args = editor.args(); - let editor_args = if args.len() > 1 { &args[1..] } else { &[] }; - let exit_status = std::process::Command::new(&args[0]) - .args(editor_args) + let exit_status = editor + .to_command() .arg(&description_file_path) .status() .map_err(|_| user_error(format!("Failed to run editor '{editor}'")))?; diff --git a/src/config.rs b/src/config.rs index 9ec07ed3d..60005b661 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,6 +13,7 @@ // limitations under the License. use std::path::PathBuf; +use std::process::Command; use std::{env, fmt}; use jujutsu_lib::settings::UserSettings; @@ -147,6 +148,14 @@ impl FullCommandArgs { FullCommandArgs::String(s) => s.split(' ').map(|s| s.to_owned()).collect(), } } + + /// Returns process builder configured with this. + pub fn to_command(&self) -> Command { + let full_args = self.args(); + let mut cmd = Command::new(&full_args[0]); + cmd.args(&full_args[1..]); + cmd + } } impl + ?Sized> From<&T> for FullCommandArgs {