From b6f68d47793957bcff58cde18bd28460e0b2d7ab Mon Sep 17 00:00:00 2001 From: maxlandon Date: Thu, 7 Sep 2023 21:08:50 +0200 Subject: [PATCH] Final fix to recursive filtering --- menu.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/menu.go b/menu.go index e0f59c6..68e9be5 100644 --- a/menu.go +++ b/menu.go @@ -226,6 +226,10 @@ func (m *Menu) CheckIsAvailable(cmd *cobra.Command) error { // does not declare as compliant with (added with console.Hide/ShowCommand()). func (m *Menu) ActiveFiltersFor(cmd *cobra.Command) []string { if cmd.Annotations == nil { + if cmd.HasParent() { + return m.ActiveFiltersFor(cmd.Parent()) + } + return nil } @@ -244,7 +248,7 @@ func (m *Menu) ActiveFiltersFor(cmd *cobra.Command) []string { } } - if len(filters) > 0 { + if len(filters) > 0 || !cmd.HasParent() { return filters }