Skip to content

Commit

Permalink
refactor count parsing of key events
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Oct 15, 2024
1 parent 7c94c6e commit e47d3e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ func (km *Manager) Press(k Key) event.Event {
keys := km.keys[i:]
var count int64
if km.count {
numStr := ""
var countStr string
for j, k := range keys {
if len(k) == 1 && ('1' <= k[0] && k[0] <= '9' || k[0] == '0' && j > 0) {
numStr += string(k)
if "1" <= k && k <= "9" || k == "0" && j > 0 {
countStr += string(k)
} else {
break
}
}
keys = keys[len(numStr):]
count, _ = strconv.ParseInt(numStr, 10, 64)
keys = keys[len(countStr):]
count, _ = strconv.ParseInt(countStr, 10, 64)
}
for _, ke := range km.events {
switch ke.cmp(keys) {
Expand Down

0 comments on commit e47d3e9

Please sign in to comment.