Skip to content

Commit

Permalink
fix: skip top-level commands without flags
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Feb 14, 2023
1 parent 9a6b4fb commit f0075d5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/autocomplete/zsh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ export default class ZshCompWithSpaces {
} else {
const cmd = this.commands.find(c => c.id === arg.id)

// if it's a command and has flags, inline flag completion statement.
if (cmd && Object.keys(cmd.flags).length > 0) {
caseBlock += `${arg.id})\n${this.genZshFlagArgumentsBlock(cmd.flags)} ;; \n`
if (cmd) {
// if it's a command and has flags, inline flag completion statement.
// skip it from the args statement if it doesn't accept any flag.
if (Object.keys(cmd.flags).length > 0) {
caseBlock += `${arg.id})\n${this.genZshFlagArgumentsBlock(cmd.flags)} ;; \n`
}
} else {
// it's a topic, redirect to its completion function.
caseBlock += `${arg.id})\n _${this.config.bin}_${arg.id}\n ;;\n`
Expand Down

0 comments on commit f0075d5

Please sign in to comment.