diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 28d59d12..04768f4e 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -311,7 +311,27 @@ func (v *View) HandleEvent(event tcell.Event) { // Window resized tabs[v.TabNum].Resize() case *tcell.EventKey: - if e.Key() == tcell.KeyRune && (e.Modifiers() == 0 || e.Modifiers() == tcell.ModShift) { + // Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune + isBinding := false + if e.Key() != tcell.KeyRune || e.Modifiers() != 0 { + for key, actions := range bindings { + if e.Key() == key.keyCode { + if e.Key() == tcell.KeyRune { + if e.Rune() != key.r { + continue + } + } + if e.Modifiers() == key.modifiers { + relocate = false + isBinding = true + for _, action := range actions { + relocate = action(v, true) || relocate + } + } + } + } + } + if !isBinding && e.Key() == tcell.KeyRune { // Insert a character if v.Cursor.HasSelection() { v.Cursor.DeleteSelection() @@ -326,22 +346,6 @@ func (v *View) HandleEvent(event tcell.Event) { TermMessage(err) } } - } else { - for key, actions := range bindings { - if e.Key() == key.keyCode { - if e.Key() == tcell.KeyRune { - if e.Rune() != key.r { - continue - } - } - if e.Modifiers() == key.modifiers { - relocate = false - for _, action := range actions { - relocate = action(v, true) || relocate - } - } - } - } } case *tcell.EventPaste: if !PreActionCall("Paste", v) {