diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/binds.go | 2 | ||||
-rw-r--r-- | config/binds_test.go | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/config/binds.go b/config/binds.go index 3ddc2578..1d391af7 100644 --- a/config/binds.go +++ b/config/binds.go @@ -473,7 +473,7 @@ func FormatKeyStrokes(keystrokes []KeyStroke) string { for _, stroke := range keystrokes { s := "" for name, ks := range keyNames { - if ks.Modifiers == stroke.Modifiers && ks.Key == stroke.Key { + if (ks.Modifiers == stroke.Modifiers || ks.Modifiers == vaxis.ModifierMask(0)) && ks.Key == stroke.Key { switch name { case "cr": s = "<enter>" diff --git a/config/binds_test.go b/config/binds_test.go index 7d4cd779..7325252d 100644 --- a/config/binds_test.go +++ b/config/binds_test.go @@ -85,3 +85,17 @@ func TestGetBinding(t *testing.T) { {vaxis.ModShift, vaxis.KeyUp}, }, BINDING_FOUND, ":open") } + +func TestKeyStrokeFormatting(t *testing.T) { + tests := []struct { + stroke KeyStroke + formatted string + }{ + {KeyStroke{vaxis.ModifierMask(0), vaxis.KeyLeft}, "<left>"}, + {KeyStroke{vaxis.ModCtrl, vaxis.KeyLeft}, "c-<left>"}, + } + + for _, test := range tests { + assert.Equal(t, test.formatted, FormatKeyStrokes([]KeyStroke{test.stroke})) + } +} |