Merge pull request #9395 from dotCooCoo/fix/pathfinder-repeat-label

Pathfinder: the Repeat row names the last operation
This commit is contained in:
BFlat authored and GitHub committed 2026-11-26 23:18:22 +07:00
commit c46cc9ecd4
2 files changed
+36

No files matched your search

+14
View File
@@ -100,6 +100,11 @@ fn command_label(app: &VectorcraftApp, id: &str, label: &str) -> Option<String>
Some((e, _)) => format!("Last Effect: {}", vectorcraft_effects::effect_info(e).map(|i| i.label).unwrap_or(e.as_str())),
None => label.into(),
},
// Repeat Pathfinder is named after the Shape Mode or Pathfinder operation that ran last.
"pathfinder.repeat" => match last_pathfinder_label(app) {
Some(name) => format!("Repeat {name}"),
None => label.into(),
},
// Apply Last Filter and Last Filter… are named after the filter that ran last.
crate::dialogs::plugin::APPLY_LAST | crate::dialogs::plugin::LAST => match crate::dialogs::plugin::last_filter_name(app) {
Some(name) if id == crate::dialogs::plugin::APPLY_LAST => format!("Apply {name}"),
@@ -130,6 +135,11 @@ fn command_label(app: &VectorcraftApp, id: &str, label: &str) -> Option<String>
Some(text)
}
/// The Pathfinder panel's name for the Shape Mode or Pathfinder operation that ran last.
fn last_pathfinder_label(app: &VectorcraftApp) -> Option<&'static str> {
app.last_pathfinder.as_deref().and_then(crate::panels::pathfinder::operation_label)
}
/// Does the menu item `id` show a name that is user, file or system data rather than an interface
/// label: a recent file, a saved view, a font, a user library or preset, a custom workspace, a
/// plug-in, an SVG filter, a script of the Scripts folder? Such names are shown as they are, never
@@ -202,6 +212,10 @@ pub fn display_label(app: &VectorcraftApp, id: &str, label: &str) -> String {
}
None => crate::i18n::tr_id(lang, id, label).to_string(),
},
"pathfinder.repeat" => match last_pathfinder_label(app) {
Some(name) => fmt(tl!("Repeat {name}"), &[("name", tl!(name))]),
None => crate::i18n::tr_id(lang, id, label).to_string(),
},
// The filter's name is the plug-in's own text, never translated.
crate::dialogs::plugin::APPLY_LAST | crate::dialogs::plugin::LAST => match crate::dialogs::plugin::last_filter_name(app) {
Some(name) if id == crate::dialogs::plugin::APPLY_LAST => fmt(tl!("Apply {filter}"), &[("filter", &name)]),
+22
View File
@@ -520,6 +520,28 @@ mod tests {
assert!(p.app().run("pathfinder.repeat", json!({})).is_err());
}
/// The state the window's menus give the Repeat row, which the panel menu's row reads.
fn repeat_row(p: &Panel) -> Option<CommandState> {
crate::menus::model::refresh(&mut p.app(), p.ctx());
p.app().menus.states.get(&CommandRef::new("pathfinder.repeat")).cloned()
}
/// Before an operation has run, the Repeat row reads Repeat Pathfinder and is dimmed; after Unite
/// or Minus Front from the panel it names that operation.
#[test]
fn the_repeat_row_names_the_last_operation() {
let mut p = Panel::new(two_squares(), show);
let command = CommandRef::new("pathfinder.repeat");
let off = crate::menus::model::off_reason(&p.app(), &command, "Repeat Pathfinder");
assert_eq!(repeat_row(&p), Some(CommandState::new().enabled(false).hint(off)), "the plain label, dimmed");
p.click("Unite");
select_two_squares(&mut p.app(), 110.0);
assert_eq!(repeat_row(&p), Some(CommandState::new().enabled(true).title("Repeat Unite")));
p.click("Minus Front");
select_two_squares(&mut p.app(), 210.0);
assert_eq!(repeat_row(&p), Some(CommandState::new().enabled(true).title("Repeat Minus Front")));
}
/// One selected path cannot supply the operands for Unite; the command reports the failure.
#[test]
fn repeat_with_one_path_keeps_art_and_history() {