@@ -217,20 +217,6 @@ export class RootCommand extends Command {
217217 }
218218 }
219219
220- // Fallback: if nothing matched yet, try to match any single-token command
221- // later in the args (helps when the executable name or runner is included,
222- // e.g., `pnpm nuxt dev` where `nuxt` is not a registered command).
223- if ( ! matchedCommand ) {
224- for ( let i = 0 ; i < args . length ; i ++ ) {
225- const potential = this . commands . get ( args [ i ] ) ;
226- if ( potential ) {
227- matchedCommand = potential ;
228- remaining = args . slice ( i + 1 ) ;
229- break ;
230- }
231- }
232- }
233-
234220 // If no command was matched, use the root command (this)
235221 return [ matchedCommand || this , remaining ] ;
236222 }
@@ -273,12 +259,9 @@ export class RootCommand extends Command {
273259 // Determine if we should complete commands
274260 private shouldCompleteCommands (
275261 toComplete : string ,
276- endsWithSpace : boolean ,
277- isRootCommandContext : boolean
262+ endsWithSpace : boolean
278263 ) : boolean {
279- // Only suggest commands when we're still completing at the root context.
280- // Once a command is matched, we should move on to its arguments/flags.
281- return isRootCommandContext && ! toComplete . startsWith ( '-' ) ;
264+ return ! toComplete . startsWith ( '-' ) ;
282265 }
283266
284267 // Handle flag completion (names and values)
@@ -474,7 +457,6 @@ export class RootCommand extends Command {
474457 }
475458
476459 const [ matchedCommand ] = this . matchCommand ( previousArgs ) ;
477- const isRootContext = matchedCommand === this ;
478460 const lastPrevArg = previousArgs [ previousArgs . length - 1 ] ;
479461
480462 // 1. Handle flag/option completion
@@ -508,9 +490,7 @@ export class RootCommand extends Command {
508490 }
509491
510492 // 2. Handle command/subcommand completion
511- if (
512- this . shouldCompleteCommands ( toComplete , endsWithSpace , isRootContext )
513- ) {
493+ if ( this . shouldCompleteCommands ( toComplete , endsWithSpace ) ) {
514494 this . handleCommandCompletion ( previousArgs , toComplete ) ;
515495 }
516496 // 3. Handle positional arguments - always check for root command arguments
0 commit comments