Skip to content

Commit 8986c83

Browse files
committed
fallback
1 parent 92ef3f1 commit 8986c83

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/t.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/zsh.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)