remove unwrap from controller modifier handler

This commit is contained in:
Maxicarlos08 2023-09-18 17:34:38 +02:00
parent b9c33df635
commit 3f6d23ad7f
No known key found for this signature in database

View File

@ -602,8 +602,14 @@ impl Window {
if settings.modifier_buttons.contains(button) {
if is_pressed {
modifiers.push(*button);
} else {
let index = modifiers.iter().position(|x| x == button).unwrap();
// There is a possibility of voxygen not having
// registered the initial press event (either because it
// hadn't started yet, or whatever else) hence the
// modifier has no position in the list, unwrapping
// here would cause a crash in those cases
} else if let Some(index) =
modifiers.iter().position(|modifier| modifier == button)
{
modifiers.remove(index);
}
}