diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index f4824a38117..9ff740674a2 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -977,39 +977,41 @@ fn events( break; } } + Event::Key { - key: Key::Z, + key, pressed: true, modifiers, .. - } if modifiers.matches_logically(Modifiers::COMMAND) => { - if let Some((undo_ccursor_range, undo_txt)) = state + } if (modifiers.matches_logically(Modifiers::COMMAND) && *key == Key::Y) + || (modifiers.matches_logically(Modifiers::SHIFT | Modifiers::COMMAND) + && *key == Key::Z) => + { + if let Some((redo_ccursor_range, redo_txt)) = state .undoer .lock() - .undo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned())) + .redo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned())) { - text.replace_with(undo_txt); - Some(*undo_ccursor_range) + text.replace_with(redo_txt); + Some(*redo_ccursor_range) } else { None } } + Event::Key { - key, + key: Key::Z, pressed: true, modifiers, .. - } if (modifiers.matches_logically(Modifiers::COMMAND) && *key == Key::Y) - || (modifiers.matches_logically(Modifiers::SHIFT | Modifiers::COMMAND) - && *key == Key::Z) => - { - if let Some((redo_ccursor_range, redo_txt)) = state + } if modifiers.matches_logically(Modifiers::COMMAND) => { + if let Some((undo_ccursor_range, undo_txt)) = state .undoer .lock() - .redo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned())) + .undo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned())) { - text.replace_with(redo_txt); - Some(*redo_ccursor_range) + text.replace_with(undo_txt); + Some(*undo_ccursor_range) } else { None }