From a2af6a89abb13cbf255988f28676c849814be45e Mon Sep 17 00:00:00 2001 From: Vitaly Ovchinnikov Date: Sun, 24 Sep 2023 09:56:49 +0000 Subject: binds: better processing of contextual binds Fix bindings for groups like [compose::review:account=acc1], adds a proper handling of $noinherit=true for contextual bindings. Without the patch contexts like [compose::review:account=acc1] are matching the [view] context which produces errors. Replacing `Contains` with `HasPrefix` seems to be the right thing there. Another change lets you really drop all the previous bindings if the contextual binding has $noinherit=true. Without that the parent bindings are still there regardless of $noinherit flag. Signed-off-by: Vitaly Ovchinnikov Reviewed-by: Koni Marti Acked-by: Robin Jarry --- config/binds.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'config/binds.go') diff --git a/config/binds.go b/config/binds.go index 1e9727a5..1b2799f2 100644 --- a/config/binds.go +++ b/config/binds.go @@ -200,8 +200,8 @@ func LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error } for _, sectionName := range binds.SectionStrings() { - if !strings.Contains(sectionName, baseName+":") || - strings.Contains(sectionName, baseName+"::") { + if !strings.HasPrefix(sectionName, baseName+":") || + strings.HasPrefix(sectionName, baseName+"::") { continue } @@ -276,6 +276,9 @@ func MergeBindings(bindings ...*KeyBindings) *KeyBindings { merged := NewKeyBindings() for _, b := range bindings { merged.Bindings = append(merged.Bindings, b.Bindings...) + if !b.Globals { + break + } } merged.ExKey = bindings[0].ExKey merged.Globals = bindings[0].Globals -- cgit