mirror of
https://github.com/spf13/cobra
synced 2025-04-27 00:57:23 +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)
|
||||
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue