summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2021-04-07 23:21:34 +0200
committerDaniel Milde <daniel@milde.cz>2021-04-07 23:21:34 +0200
commit693327c054162bc874ce88553b6784552c116a77 (patch)
tree6bb7182ed2ee3e93bea296ff9bf7f71e6bae2b7c
parent26e6a0019657ddaa7c6d9c1ff866050c83279e3a (diff)
do not pass key further if matchedv4.10.0
fixes #39
-rw-r--r--tui/keys.go8
-rw-r--r--tui/keys_test.go2
2 files changed, 6 insertions, 4 deletions
diff --git a/tui/keys.go b/tui/keys.go
index 1e0e711..b87cb22 100644
--- a/tui/keys.go
+++ b/tui/keys.go
@@ -32,12 +32,12 @@ func (ui *UI) keyPressed(key *tcell.EventKey) *tcell.EventKey {
if key.Rune() == 'h' || key.Key() == tcell.KeyLeft {
ui.handleLeft()
- return key
+ return nil
}
if key.Rune() == 'l' || key.Key() == tcell.KeyRight {
ui.handleRight()
- return key
+ return nil
}
switch key.Rune() {
@@ -62,8 +62,10 @@ func (ui *UI) keyPressed(key *tcell.EventKey) *tcell.EventKey {
ui.setSorting("itemCount")
case 'n':
ui.setSorting("name")
+ default:
+ return key
}
- return key
+ return nil
}
func (ui *UI) handleLeft() {
diff --git a/tui/keys_test.go b/tui/keys_test.go
index 95a035e..9210b96 100644
--- a/tui/keys_test.go
+++ b/tui/keys_test.go
@@ -157,7 +157,7 @@ func TestDeleteEmpty(t *testing.T) {
ui.done = make(chan struct{})
key := ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'd', 0))
- assert.Equal(t, 'd', key.Rune())
+ assert.Nil(t, key)
}
func TestDelete(t *testing.T) {