Repository navigation
fix: off-by-one bounds check in KeyMap.unbind() - #1735
Conversation
🤖 Augment PR SummarySummary: Fixes an off-by-one bounds check in Changes:
Notes: This aligns unbind/bind behavior around the fixed-size keymap table ( 🤖 Was this summary useful? React with 👍 or 👎 |
|
|
||
| // Unbinding a multi-char sequence where the final char is at the boundary | ||
| map.bind("action", "a"); | ||
| map.unbind("a" + boundaryChar); |
There was a problem hiding this comment.
map.unbind("a" + boundaryChar) doesn’t currently exercise the “final char is at the boundary” path: after map.bind("action", "a"), map.mapping['a'] is not a KeyMap, so KeyMap.unbind(..) returns early before checking the last character’s bounds. This makes the test comment a bit misleading and may leave the multi-char-final-char boundary case untested.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|



Summary
KeyMap.unbind()where bounds checks on lines 631 and 641 used>instead of>=, causingArrayIndexOutOfBoundsExceptionwhen a character's value equalsmapping.length(128)bind()method already correctly uses>=at line 672; this alignsunbind()with the same patternTest plan
testUnbindBoundaryChartest verifies unbinding a key sequence with char value == KEYMAP_LENGTH returns gracefully without throwing