Skip to content

Commit

Permalink
fix: a bug where left/right keys would trigger item selection
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Jan 10, 2023
1 parent 3a50b92 commit 21e0044
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/model/simplelist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ func (m Model) SelectedItem() list.Item {
// GetItem checks if the list has an item by a [0-9] index and also
// a [a-z] index if the list has more than 10 elements
func (m Model) GetItem(text string) (list.Item, bool) {
// Convert the text to an integer and
// check if the index is in the list
// Check if the string is more than one character (left, right, up, down, etc)
if len(text) > 1 {
return nil, false
}

// Convert the text to an integer and check if the index is in the list
if index, err := strconv.Atoi(text); err == nil {
inList := index < len(m.items)
if !inList {
Expand Down

0 comments on commit 21e0044

Please sign in to comment.