diff --git a/crates/nu-cli/src/completions.rs b/crates/nu-cli/src/completions.rs index 43215fac80..30c60a5fb1 100644 --- a/crates/nu-cli/src/completions.rs +++ b/crates/nu-cli/src/completions.rs @@ -150,8 +150,8 @@ impl NuCompleter { .find_commands_by_prefix(prefix) .into_iter() .map(move |x| Suggestion { - value: String::from_utf8_lossy(&x).to_string(), - description: None, + value: String::from_utf8_lossy(&x.0).to_string(), + description: x.1, span: reedline::Span { start: span.start - offset, end: span.end - offset, diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 9ba7bf801e..13cda33906 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -443,13 +443,14 @@ impl EngineState { None } - pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec> { + pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<(Vec, Option)> { let mut output = vec![]; for scope in self.scope.iter().rev() { for decl in &scope.decls { if decl.0.starts_with(name) { - output.push(decl.0.clone()); + let command = self.get_decl(*decl.1); + output.push((decl.0.clone(), Some(command.usage().to_string()))); } } } @@ -1296,13 +1297,14 @@ impl<'a> StateWorkingSet<'a> { } } - pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec> { + pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<(Vec, Option)> { let mut output = vec![]; for scope in self.delta.scope.iter().rev() { for decl in &scope.decls { if decl.0.starts_with(name) { - output.push(decl.0.clone()); + let command = self.get_decl(*decl.1); + output.push((decl.0.clone(), Some(command.usage().to_string()))); } } }