mirror of
https://github.com/spf13/cobra
synced 2025-04-27 17:17:20 +00:00
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:
parent
79fb3dd0cf
commit
3f1c31c21e
1 changed files with 4 additions and 5 deletions
|
@ -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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue