Skip to content

Commit

Permalink
Avoid redundant active help enablement evaluations
Browse files Browse the repository at this point in the history
The enablement state is not to be changed during completion output, so
evaluate it only once.
  • Loading branch information
scop committed May 9, 2023
1 parent b958f23 commit 72ab0a8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,12 @@ func (c *Command) initCompleteCmd(args []string) {
}

noDescriptions := (cmd.CalledAs() == ShellCompNoDescRequestCmd)
noActiveHelp := GetActiveHelpConfig(finalCmd) == activeHelpGlobalDisable
out := finalCmd.OutOrStdout()
for _, comp := range completions {
if GetActiveHelpConfig(finalCmd) == activeHelpGlobalDisable {
// Remove all activeHelp entries in this case
if strings.HasPrefix(comp, activeHelpMarker) {
continue
}
if noActiveHelp && strings.HasPrefix(comp, activeHelpMarker) {
// Remove all activeHelp entries if it's disabled.
continue
}
if noDescriptions {
// Remove any description that may be included following a tab character.
Expand Down

0 comments on commit 72ab0a8

Please sign in to comment.