diff --git a/crates/nu-command/src/core_commands/help.rs b/crates/nu-command/src/core_commands/help.rs index f1a487d163..983dbb4c99 100644 --- a/crates/nu-command/src/core_commands/help.rs +++ b/crates/nu-command/src/core_commands/help.rs @@ -86,15 +86,15 @@ You can also learn more at https://www.nushell.sh/book/"#; } else if find.is_some() { help_commands(engine_state, stack, call) } else { - let result = help_commands(engine_state, stack, call); + let result = help_aliases(engine_state, stack, call); - let result = if let Err(ShellError::CommandNotFound(_)) = result { - help_aliases(engine_state, stack, call) + let result = if let Err(ShellError::AliasNotFound(_)) = result { + help_commands(engine_state, stack, call) } else { result }; - let result = if let Err(ShellError::AliasNotFound(_)) = result { + let result = if let Err(ShellError::CommandNotFound(_)) = result { help_modules(engine_state, stack, call) } else { result diff --git a/crates/nu-command/tests/commands/help.rs b/crates/nu-command/tests/commands/help.rs index 865659a8b2..0ced68a839 100644 --- a/crates/nu-command/tests/commands/help.rs +++ b/crates/nu-command/tests/commands/help.rs @@ -342,3 +342,15 @@ fn help_modules_main_2() { assert_eq!(actual.out, "spam"); } + +#[test] +fn help_alias_before_command() { + let code = &[ + "alias SPAM = print 'spam'", + "def SPAM [] { 'spam' }", + "help SPAM", + ]; + let actual = nu!(cwd: ".", nu_repl_code(code)); + + assert!(actual.out.contains("Alias")); +}