chore(lint): extract a magic number when parsing X10 mouse events

This commit is contained in:
Christian Rocha 2023-07-07 11:35:46 -04:00
parent 522659d798
commit c284acad9f
1 changed files with 3 additions and 2 deletions

5
key.go
View File

@ -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,