diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 155d6e557..d8d875e2e 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -2294,11 +2294,12 @@ pub fn run_ui_editor(settings: &UserSettings, edit_path: &PathBuf) -> Result<(), .config() .get("ui.editor") .map_err(|err| CommandError::ConfigError(format!("ui.editor: {err}")))?; - let exit_status = editor - .to_command() - .arg(edit_path) - .status() - .map_err(|_| user_error(format!("Failed to run editor '{editor}'")))?; + let exit_status = editor.to_command().arg(edit_path).status().map_err(|err| { + user_error(format!( + "Failed to run editor '{name}': {err}", + name = editor.split_name(), + )) + })?; if !exit_status.success() { return Err(user_error(format!( "Editor '{editor}' exited with an error" diff --git a/cli/src/config.rs b/cli/src/config.rs index 2060605f9..453d7dabe 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -447,6 +447,12 @@ pub enum CommandNameAndArgs { } impl CommandNameAndArgs { + /// Returns command name without arguments. + pub fn split_name(&self) -> Cow { + let (name, _) = self.split_name_and_args(); + name + } + /// Returns command name and arguments. /// /// The command name may be an empty string (as well as each argument.) diff --git a/cli/src/ui.rs b/cli/src/ui.rs index a94c125ef..0479aac4c 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -224,8 +224,8 @@ impl Ui { Err(e) => { writeln!( self.warning(), - "Failed to spawn pager '{cmd}': {e}", - cmd = self.pager_cmd, + "Failed to spawn pager '{name}': {e}", + name = self.pager_cmd.split_name(), ) .ok(); }