Ignore out-of-range mouse button values using from_bits_truncate (#3541)

* fix: ignore out-of-range mouse button values using from_bits_truncate

* Apply suggestion from @TrueDoctor

* Fix formatting

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
Ayush Amawate 2026-01-12 04:01:15 +05:30 committed by GitHub
parent 33e3a88458
commit 5dd11bf138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -76,7 +76,8 @@ pub struct EditorMouseState {
impl EditorMouseState {
pub fn from_keys_and_editor_position(keys: u8, editor_position: EditorPosition) -> Self {
let mouse_keys = MouseKeys::from_bits(keys).expect("Invalid decoding of MouseKeys");
// TODO: Some graphic tablets send key codes not mentioned in the spec. In the future we would like to support these as well.
let mouse_keys = MouseKeys::from_bits_truncate(keys);
Self {
editor_position,