Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Undo/Redo: the menu names the step with the History panel's own function

bflatastic015bab68a1a4
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 88759a2b4..f89f53537 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -1907,7 +1907,7 @@ pub fn display_label(app: &VectorcraftApp, id: &str, label: &str) -> String {
"edit.undo" | "edit.redo" => {
let last = app.session.active().and_then(|d| if id == "edit.undo" { d.history.undo.last() } else { d.history.redo.last() });
// The step's name as the History panel lists it.
- let name = |label: &str| crate::panels::history::step_name(lang, label).unwrap_or_else(|| label.to_string());
+ let name = crate::panels::history::shown;
match last {
Some(h) if id == "edit.undo" => fmt(tl!("Undo {name}"), &[("name", &name(&h.label))]),
Some(h) => fmt(tl!("Redo {name}"), &[("name", &name(&h.label))]),
diff --git a/crates/ui-egui/src/panels/history.rs b/crates/ui-egui/src/panels/history.rs
index 13ca7fab3..adc1d6f44 100644
--- a/crates/ui-egui/src/panels/history.rs
+++ b/crates/ui-egui/src/panels/history.rs
@@ -24,8 +24,9 @@ pub fn step_name(lang: crate::i18n::Lang, label: &str) -> Option<String> {
has(lang, &dotted).then(|| tr(lang, &dotted).trim_end_matches('…').to_string())
}
-/// A step's name as the panel lists it: in the UI language, else as recorded.
-fn shown(label: &str) -> String {
+/// A step's name as the panel lists it: in the UI language, else as recorded. Edit › Undo and Redo
+/// name the step the same way.
+pub(crate) fn shown(label: &str) -> String {
step_name(crate::i18n::current(), label).unwrap_or_else(|| label.to_string())
}