Avoid redundant active help enablement evaluations

The enablement state is not to be changed during completion output, so
evaluate it only once.
This commit is contained in:
Ville Skyttä 2023-05-10 00:03:16 +03:00
parent 79fb3dd0cf
commit 3f1c31c21e

View file

@ -217,13 +217,12 @@ func (c *Command) initCompleteCmd(args []string) {
} }
noDescriptions := (cmd.CalledAs() == ShellCompNoDescRequestCmd) noDescriptions := (cmd.CalledAs() == ShellCompNoDescRequestCmd)
noActiveHelp := GetActiveHelpConfig(finalCmd) == activeHelpGlobalDisable
out := finalCmd.OutOrStdout() out := finalCmd.OutOrStdout()
for _, comp := range completions { for _, comp := range completions {
if GetActiveHelpConfig(finalCmd) == activeHelpGlobalDisable { if noActiveHelp && strings.HasPrefix(comp, activeHelpMarker) {
// Remove all activeHelp entries in this case // Remove all activeHelp entries if it's disabled.
if strings.HasPrefix(comp, activeHelpMarker) { continue
continue
}
} }
if noDescriptions { if noDescriptions {
// Remove any description that may be included following a tab character. // Remove any description that may be included following a tab character.