]> git.lizzy.rs Git - micro.git/commitdiff
Fix unbind of a rune (#1649)
authordmaluka <dmitrymaluka@gmail.com>
Fri, 15 May 2020 01:50:28 +0000 (03:50 +0200)
committerGitHub <noreply@github.com>
Fri, 15 May 2020 01:50:28 +0000 (21:50 -0400)
Fix problem with non-working unbind of a rune key.
E.g. after the following commands:

bind "n" "FindNext"
unbind "n"

Observed result: "n" key still triggers FindNext action
Expected result: "n" key inserts "n" rune

internal/action/bindings.go
internal/action/bufpane.go

index 247202f3c9795a535faa11dab1c223241a5ec659..fd57eb9c70968bed99b35231d1e2808295651487 100644 (file)
@@ -249,6 +249,7 @@ func UnbindKey(k string) error {
                if a, ok := defaults[k]; ok {
                        BindKey(k, a)
                } else if _, ok := config.Bindings[k]; ok {
+                       BufUnmap(key)
                        delete(config.Bindings, k)
                }
 
index 0daf8afdf5c88545be53758606eeb130ea2fb238..a422f4c2406fa69d79b67d190a1279cf2652a2ed 100644 (file)
@@ -139,6 +139,17 @@ func BufMapMouse(k MouseEvent, action string) {
        }
 }
 
+// BufUnmap unmaps a key or mouse event from any action
+func BufUnmap(k Event) {
+       delete(BufKeyBindings, k)
+       delete(BufKeyStrings, k)
+
+       switch e := k.(type) {
+       case MouseEvent:
+               delete(BufMouseBindings, e)
+       }
+}
+
 // The BufPane connects the buffer and the window
 // It provides a cursor (or multiple) and defines a set of actions
 // that can be taken on the buffer