Fix Ctrl+Shift+Z redo shortcut (#5258)
This shortcut was previously triggering the Undo action due to the matches_logically method ignoring the state of the Shift key. This was solved by simply inverting the order of the undo and redo arms, so the undo is not matched if the shortcut corresponds to redo. * Closes <https://github.com/emilk/egui/issues/5255> * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
6add64e144
commit
e5c502f21e
|
|
@ -978,23 +978,7 @@ fn events(
|
|||
break;
|
||||
}
|
||||
}
|
||||
Event::Key {
|
||||
key: Key::Z,
|
||||
pressed: true,
|
||||
modifiers,
|
||||
..
|
||||
} if modifiers.matches_logically(Modifiers::COMMAND) => {
|
||||
if let Some((undo_ccursor_range, undo_txt)) = state
|
||||
.undoer
|
||||
.lock()
|
||||
.undo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned()))
|
||||
{
|
||||
text.replace_with(undo_txt);
|
||||
Some(*undo_ccursor_range)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Event::Key {
|
||||
key,
|
||||
pressed: true,
|
||||
|
|
@ -1016,6 +1000,24 @@ fn events(
|
|||
}
|
||||
}
|
||||
|
||||
Event::Key {
|
||||
key: Key::Z,
|
||||
pressed: true,
|
||||
modifiers,
|
||||
..
|
||||
} if modifiers.matches_logically(Modifiers::COMMAND) => {
|
||||
if let Some((undo_ccursor_range, undo_txt)) = state
|
||||
.undoer
|
||||
.lock()
|
||||
.undo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned()))
|
||||
{
|
||||
text.replace_with(undo_txt);
|
||||
Some(*undo_ccursor_range)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Event::Key {
|
||||
modifiers,
|
||||
key,
|
||||
|
|
|
|||
Loading…
Reference in New Issue