···193pub fn generate_command_argument_suggestions(
194 input: &str,
195 engine_guard: &EngineState,
0196 prefix: String,
197 span: Span,
198 command_name: String,
···204 );
205206 let mut suggestions = Vec::new();
00000000000000000000000000000000000000207 if let Some(signature) = get_command_signature(engine_guard, &command_name) {
208 // First, check if we're completing an argument for a flag
209 // Look backwards from the current position to find the previous flag
···552 } => generate_command_argument_suggestions(
553 input,
554 engine_guard,
0555 prefix,
556 span,
557 command_name,
···193pub fn generate_command_argument_suggestions(
194 input: &str,
195 engine_guard: &EngineState,
196+ working_set: &StateWorkingSet,
197 prefix: String,
198 span: Span,
199 command_name: String,
···205 );
206207 let mut suggestions = Vec::new();
208+209+ // If we're at argument index 0, check if the command has subcommands and add them
210+ if arg_index == 0 {
211+ let parent_prefix = format!("{} ", command_name);
212+ let search_prefix = if prefix.is_empty() {
213+ parent_prefix.clone()
214+ } else {
215+ format!("{}{}", parent_prefix, prefix)
216+ };
217+218+ let subcommands = working_set
219+ .find_commands_by_predicate(|value| value.starts_with(search_prefix.as_bytes()), true);
220+221+ if !subcommands.is_empty() {
222+ // Command has subcommands - add them to suggestions
223+ console_log!(
224+ "[completion] Command {command_name:?} has subcommands, adding subcommand suggestions for prefix: {prefix:?}"
225+ );
226+ let span = to_char_span(input, span);
227+ for (_, name, desc, _) in subcommands {
228+ let name_str = String::from_utf8_lossy(&name).to_string();
229+ if let Some(subcommand_name) = name_str.strip_prefix(&parent_prefix) {
230+ suggestions.push(Suggestion {
231+ rendered: {
232+ let name_colored = ansi_term::Color::Green.bold().paint(subcommand_name);
233+ let desc_str = desc.as_deref().unwrap_or("<no description>");
234+ format!("{name_colored} {desc_str}")
235+ },
236+ name: subcommand_name.to_string(),
237+ description: desc.map(|d| d.to_string()),
238+ span_start: span.start,
239+ span_end: span.end,
240+ });
241+ }
242+ }
243+ }
244+ }
245+246 if let Some(signature) = get_command_signature(engine_guard, &command_name) {
247 // First, check if we're completing an argument for a flag
248 // Look backwards from the current position to find the previous flag
···591 } => generate_command_argument_suggestions(
592 input,
593 engine_guard,
594+ working_set,
595 prefix,
596 span,
597 command_name,