From c284acad9f18f5563906f98bd4c5d6d27e709599 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 7 Jul 2023 11:35:46 -0400 Subject: [PATCH] chore(lint): extract a magic number when parsing X10 mouse events --- key.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/key.go b/key.go index a49152c..b712228 100644 --- a/key.go +++ b/key.go @@ -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,