Skip to content

Commit

Permalink
do not pass key further if matched
Browse files Browse the repository at this point in the history
fixes #39
  • Loading branch information
dundee committed Apr 7, 2021
1 parent 26e6a00 commit 693327c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tui/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 693327c

Please sign in to comment.