* claim: #3045 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Shift+R repeats the last tool or dialog (#3045) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Phanoob <phanoob@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -307,8 +307,8 @@ pub fn component_bodies(app: &SolveApp, id: u64) -> Vec<String> {
|
||||
/// The eight radial commands, clockwise from the top.
|
||||
pub fn radial_items(app: &SolveApp) -> Vec<Item> {
|
||||
let repeat = match &app.last_command {
|
||||
Some((_, label)) => act("ui.repeat", &format!("Repeat {label}"), "redo"),
|
||||
None => act("ui.repeat", "Repeat", "redo").on(false),
|
||||
Some((_, label)) => act("ui.repeat", &format!("Repeat {label}"), "redo").key(crate::keymap::REPEAT_KEY),
|
||||
None => act("ui.repeat", "Repeat", "redo").key(crate::keymap::REPEAT_KEY).on(false),
|
||||
};
|
||||
let delete = act("ui.delete", "Delete", "delete").key("Del").on(!app.session.selection.is_empty());
|
||||
if app.session.active_sketch.is_some() {
|
||||
@@ -464,7 +464,7 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
|
||||
let has = |f: fn(&Sel) -> bool| sel.iter().any(f);
|
||||
let mut v = Vec::new();
|
||||
if let Some((_, label)) = &app.last_command {
|
||||
v.push(act("ui.repeat", &format!("Repeat {label}"), "redo"));
|
||||
v.push(act("ui.repeat", &format!("Repeat {label}"), "redo").key(crate::keymap::REPEAT_KEY));
|
||||
v.push(Item::sep());
|
||||
}
|
||||
// Everything under the cursor, for what lies beneath something else.
|
||||
@@ -975,9 +975,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {
|
||||
}
|
||||
}
|
||||
"ui.repeat" => {
|
||||
if let Some((id, _)) = app.last_command.clone() {
|
||||
app.start(&id);
|
||||
}
|
||||
app.repeat_last();
|
||||
}
|
||||
"ui.selectOther" => {
|
||||
crate::select_other::open(app, at);
|
||||
|
||||
@@ -11,8 +11,12 @@ use solidcraft_engine::command_specs;
|
||||
use crate::SolveApp;
|
||||
use crate::ui_kit;
|
||||
|
||||
/// Repeats the last tool or dialog started (`SolveApp::repeat_last`, #3045).
|
||||
pub const REPEAT_KEY: &str = "Shift+R";
|
||||
|
||||
/// Keys the application handles before any command shortcut.
|
||||
pub const RESERVED: &[&str] = &[
|
||||
REPEAT_KEY,
|
||||
"Escape",
|
||||
"S",
|
||||
"V",
|
||||
@@ -379,6 +383,33 @@ mod tests {
|
||||
assert_eq!(effective(&b, "solid.move").as_deref(), Some("M"));
|
||||
assert_eq!(key_name(egui::Key::K, egui::Modifiers { ctrl: true, shift: true, ..Default::default() }), "Ctrl+Shift+K");
|
||||
}
|
||||
|
||||
/// #3045: Shift+R starts the last tool again (here a sketch's Line after Escape put it
|
||||
/// down), R alone is still the rectangle; the menus show the key on Repeat, and no command
|
||||
/// can take it.
|
||||
#[test]
|
||||
fn shift_r_repeats_the_last_tool() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
|
||||
h.frames(2);
|
||||
h.step(&json!({"start": "sketch.line"})).unwrap();
|
||||
h.step(&json!({"key": "Escape"})).unwrap();
|
||||
h.frames(1);
|
||||
assert!(h.app.tool.is_none());
|
||||
h.step(&json!({"key": "R", "shift": true})).unwrap();
|
||||
h.frames(1);
|
||||
assert_eq!(h.app.tool.as_ref().map(|t| t.cmd.to_string()).as_deref(), Some("sketch.line"), "Shift+R starts Line again");
|
||||
h.step(&json!({"key": "Escape"})).unwrap();
|
||||
h.step(&json!({"key": "R"})).unwrap();
|
||||
h.frames(1);
|
||||
let rectangle = h.app.tool.as_ref().map(|t| t.cmd.to_string()).unwrap_or_default();
|
||||
assert!(rectangle.starts_with("sketch.rectangle"), "R alone: {rectangle}");
|
||||
let repeat = crate::context_menu::radial_items(&h.app).into_iter().find(|i| i.id == "ui.repeat").unwrap();
|
||||
assert_eq!(repeat.shortcut, REPEAT_KEY);
|
||||
let mut a = app();
|
||||
assert!(bind(&mut a, "solid.extrude", REPEAT_KEY, true).is_err(), "Shift+R is the app's");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -810,6 +810,14 @@ impl SolveApp {
|
||||
workspace::sync_context(self);
|
||||
}
|
||||
|
||||
/// Start the last tool or dialog started again (Repeat in the menus, Shift+R; #3045).
|
||||
/// `false` when none was started yet.
|
||||
pub fn repeat_last(&mut self) -> bool {
|
||||
let Some((id, _)) = self.last_command.clone() else { return false };
|
||||
self.start(&id);
|
||||
true
|
||||
}
|
||||
|
||||
/// Start a command the way a toolbar click does: interactive tools and dialogs for commands
|
||||
/// that have them, otherwise run it with defaults.
|
||||
pub fn start(&mut self, id: &str) {
|
||||
|
||||
@@ -1845,6 +1845,9 @@ pub fn shortcuts(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
app.start("ui.palette");
|
||||
}
|
||||
Key::V => crate::context_menu::toggle_visibility(app),
|
||||
Key::R if mods.shift && !mods.alt => {
|
||||
app.repeat_last();
|
||||
}
|
||||
Key::F2 => {
|
||||
let at = ctx.input(|i| i.pointer.latest_pos()).unwrap_or(ctx.content_rect().center());
|
||||
crate::context_menu::rename_selection(app, at);
|
||||
|
||||
Reference in New Issue
Block a user