File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,20 @@ 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+
220234 // If no command was matched, use the root command (this)
221235 return [ matchedCommand || this , remaining ] ;
222236 }
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ _${name}() {
3939 __${ name } _debug "Detected trailing space in buffer"
4040 fi
4141
42+ # When completing a brand-new (empty) word, CURRENT can point past the end
43+ # of the words array. Pad with an empty element so downstream logic keeps
44+ # the last typed argument (avoids replaying the prior completion).
45+ if [ $isNewWord -eq 1 ] && [ \${#words[@]} -lt \${CURRENT} ]; then
46+ __${ name } _debug "Padding words to CURRENT with empty element"
47+ words+=("")
48+ fi
49+
4250 # The user could have moved the cursor backwards on the command-line.
4351 # We need to trigger completion from the $CURRENT location, so we need
4452 # to truncate the command-line ($words) up to the $CURRENT location.
You can’t perform that action at this time.
0 commit comments