Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6a8fb7d

Browse files
committedOct 15, 2024·
refactor count parsing of key events
1 parent dc20ecf commit 6a8fb7d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎key/key.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ func (km *Manager) Press(k Key) event.Event {
6565
keys := km.keys[i:]
6666
var count int64
6767
if km.count {
68-
numStr := ""
68+
var countStr string
6969
for j, k := range keys {
70-
if len(k) == 1 && ('1' <= k[0] && k[0] <= '9' || k[0] == '0' && j > 0) {
71-
numStr += string(k)
70+
if "1" <= k && k <= "9" || k == "0" && j > 0 {
71+
countStr += string(k)
7272
} else {
7373
break
7474
}
7575
}
76-
keys = keys[len(numStr):]
77-
count, _ = strconv.ParseInt(numStr, 10, 64)
76+
keys = keys[len(countStr):]
77+
count, _ = strconv.ParseInt(countStr, 10, 64)
7878
}
7979
for _, ke := range km.events {
8080
switch ke.cmp(keys) {

0 commit comments

Comments
 (0)
Please sign in to comment.