From fb35e0312a3d2e9456b966e362fa2356931fc62b Mon Sep 17 00:00:00 2001 From: dmaluka Date: Fri, 15 May 2020 03:50:28 +0200 Subject: [PATCH] Fix unbind of a rune (#1649) 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 | 1 + internal/action/bufpane.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/internal/action/bindings.go b/internal/action/bindings.go index 247202f3..fd57eb9c 100644 --- a/internal/action/bindings.go +++ b/internal/action/bindings.go @@ -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) } diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index 0daf8afd..a422f4c2 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -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