Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
handle all parent names for zsh completions
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Nov 26, 2023
1 parent a7b2f69 commit e777e76
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/internal/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1330,23 +1330,24 @@ const getZshSubcommandCases = (
}
case "Subcommands": {
const nextSubcommands = getImmediateSubcommands(self.child as Instruction)
const parentName = Array.from(getNamesInternal(self.parent as Instruction))[0]
const parentNames = Array.from(getNamesInternal(self.parent as Instruction))
const parentLines = getZshSubcommandCases(
self.parent as Instruction,
parentCommands,
ReadonlyArray.appendAll(subcommands, nextSubcommands)
)
const childCases = getZshSubcommandCases(
self.child as Instruction,
ReadonlyArray.append(parentCommands, parentName),
ReadonlyArray.appendAll(parentCommands, parentNames),
subcommands
)
const hyphenName = pipe(
ReadonlyArray.append(parentCommands, parentName),
ReadonlyArray.appendAll(parentCommands, parentNames),
ReadonlyArray.join("-")
)
const childLines = pipe(
[
parentNames,
ReadonlyArray.flatMap((parentName) => [
"case $state in",
` (${parentName})`,
` words=($line[1] "\${words[@]}")`,
Expand All @@ -1357,7 +1358,7 @@ const getZshSubcommandCases = (
" esac",
" ;;",
"esac"
],
]),
ReadonlyArray.appendAll(
ReadonlyArray.isEmptyReadonlyArray(parentCommands)
? ReadonlyArray.empty()
Expand Down

0 comments on commit e777e76

Please sign in to comment.