Skip to content

Commit

Permalink
chore(lint): extract a magic number when parsing X10 mouse events
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jul 10, 2023
1 parent 522659d commit c284aca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,9 @@ var unknownCSIRe = regexp.MustCompile(`^\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e

func detectOneMsg(b []byte) (w int, msg Msg) {
// Detect mouse events.
if len(b) >= 6 && b[0] == '\x1b' && b[1] == '[' && b[2] == 'M' {
return 6, MouseMsg(parseX10MouseEvent(b))
const mouseEventLen = 6
if len(b) >= mouseEventLen && b[0] == '\x1b' && b[1] == '[' && b[2] == 'M' {
return mouseEventLen, MouseMsg(parseX10MouseEvent(b))
}

// Detect escape sequence and control characters other than NUL,
Expand Down

0 comments on commit c284aca

Please sign in to comment.