aboutsummaryrefslogtreecommitdiffstats
path: root/config/binds.go
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@postbox.nz>2023-09-24 09:56:49 +0000
committerRobin Jarry <robin@jarry.cc>2023-10-13 00:06:54 +0200
commita2af6a89abb13cbf255988f28676c849814be45e (patch)
tree7ca7bd288a04af5dee4c8b605a7681b0d19d13e6 /config/binds.go
parentedb510c2a6d3c3b1bf60c99c1585b91117088262 (diff)
downloadaerc-a2af6a89abb13cbf255988f28676c849814be45e.tar.gz
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 <v@postbox.nz> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config/binds.go')
-rw-r--r--config/binds.go7
1 files changed, 5 insertions, 2 deletions
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