fix(command): better error when command not found (#1829)

* fix(command): better error when command not found

* fix(cli): open edit file from current cwd

* style(fmt): rustfmt?
This commit is contained in:
Aram Drevekenin 2022-10-20 17:27:44 +02:00 committed by GitHub
parent 8431b9e0ef
commit b94a626959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -751,7 +751,7 @@ fn send_command_not_found_to_screen(
senders
.send_to_screen(ScreenInstruction::PtyBytes(
terminal_id,
format!("Command not found: {}", run_command.command.display())
format!("Command not found: {}\n\rIf you were including arguments as part of the command, try including them as 'args' instead.", run_command.command.display())
.as_bytes()
.to_vec(),
))

View file

@ -295,12 +295,20 @@ impl Action {
file,
line_number,
floating,
} => Ok(vec![Action::EditFile(
} => {
let mut file = file;
if file.is_relative() {
if let Some(cwd) = std::env::current_dir().ok() {
file = cwd.join(file);
}
}
Ok(vec![Action::EditFile(
file,
line_number,
direction,
floating,
)]),
)])
},
CliAction::SwitchMode { input_mode } => {
Ok(vec![Action::SwitchModeForAllClients(input_mode)])
},