Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: key.go missing sgr event len calculation #841

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,16 @@
func detectOneMsg(b []byte) (w int, msg Msg) {
// Detect mouse events.
// X10 mouse events have a length of 6 bytes
const mouseEventLen = 6
if len(b) >= mouseEventLen && b[0] == '\x1b' && b[1] == '[' {
const mouseEventX10Len = 6
if len(b) >= mouseEventX10Len && b[0] == '\x1b' && b[1] == '[' {
switch b[2] {
case 'M':
return mouseEventLen, MouseMsg(parseX10MouseEvent(b))
return mouseEventX10Len, MouseMsg(parseX10MouseEvent(b))
case '<':
if mouseSGRRegex.Match(b[3:]) {
return mouseEventLen, MouseMsg(parseSGRMouseEvent(b))
if matchIndices := mouseSGRRegex.FindSubmatchIndex(b[3:]); matchIndices != nil {
// SGR mouse events length is the length of the match plus the length of the escape sequence
mouseEventSGRLen := matchIndices[1] + 3

Check failure on line 586 in key.go

View workflow job for this annotation

GitHub Actions / lint-soft

mnd: Magic number: 3, in <operation> detected (gomnd)
return mouseEventSGRLen, MouseMsg(parseSGRMouseEvent(b))
}
}
}
Expand Down
Loading