* claim: #7077 * Repeat Last Command in command search, with a key you can change (#7077) Shift+R already started the last tool or dialog again (#3045), but it was a key the app kept for itself: command search could not find it and Keyboard Shortcuts could not change it. It is now the command edit.repeat, with Shift+R as its default key. A call through the engine is refused, because only the app has a tool to start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Locales: Arabic and Hebrew for the new strings ar and he are complete catalogs on main now (#3458): every new message needs them. The pending-messages test compares right-to-left messages in display order once #7532 lands (#7527). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Locales: Vietnamese for the new strings Vietnamese became a complete catalog on main (#5823), so every new English message needs it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"en": {
|
||||
"cmd.edit_repeat": "Repeat Last Command",
|
||||
"ui.repeat_nothing": "Nothing to repeat yet: start a tool or dialog first."
|
||||
},
|
||||
"ar": {
|
||||
"cmd.edit_repeat": "تكرار آخر أمر",
|
||||
"ui.repeat_nothing": "لا يوجد ما يُكرَّر بعد: ابدأ أداة أو مربع حوار أولًا."
|
||||
},
|
||||
"de": {
|
||||
"cmd.edit_repeat": "Letzten Befehl wiederholen",
|
||||
"ui.repeat_nothing": "Noch nichts zu wiederholen: Starten Sie zuerst ein Werkzeug oder einen Dialog."
|
||||
},
|
||||
"he": {
|
||||
"cmd.edit_repeat": "חזרה על הפקודה האחרונה",
|
||||
"ui.repeat_nothing": "אין עדיין מה לחזור עליו: התחל קודם כלי או תיבת דו־שיח."
|
||||
},
|
||||
"ja": {
|
||||
"cmd.edit_repeat": "最後のコマンドを繰り返す",
|
||||
"ui.repeat_nothing": "まだ繰り返すものがありません。先にツールかダイアログを開始してください。"
|
||||
},
|
||||
"ko": {
|
||||
"cmd.edit_repeat": "마지막 명령 반복",
|
||||
"ui.repeat_nothing": "아직 반복할 것이 없습니다. 먼저 도구나 대화 상자를 시작하세요."
|
||||
},
|
||||
"vi": {
|
||||
"cmd.edit_repeat": "Lặp lại lệnh trước",
|
||||
"ui.repeat_nothing": "Chưa có gì để lặp lại: hãy bắt đầu một công cụ hoặc hộp thoại trước."
|
||||
},
|
||||
"zh": {
|
||||
"cmd.edit_repeat": "重复上一个命令",
|
||||
"ui.repeat_nothing": "还没有可重复的操作:请先启动一个工具或对话框。"
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,14 @@ use crate::{EngineError, Result, Sel, Session, Snapshot};
|
||||
pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("edit.undo", "Undo", undo).icon("undo").key("Ctrl+Z").noundo().doc_only(),
|
||||
CommandSpec::new("edit.redo", "Redo", redo).icon("redo").key("Ctrl+Y").noundo().doc_only(),
|
||||
CommandSpec::new("edit.repeat", "Repeat Last Command", crate::checked!("edit.repeat", repeat))
|
||||
.icon("redo")
|
||||
.key("Shift+R")
|
||||
.noundo()
|
||||
.doc_only()
|
||||
.contract(&REPEAT_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::edit::RepeatResult>)
|
||||
.params("Starts the last tool or dialog started in the app again, with its defaults (a toolbar click, not a replay of its values). Only the app has a tool to start: called here it is refused, and changes nothing"),
|
||||
CommandSpec::new("edit.checkpoint", "Checkpoint", checkpoint).icon("checkpoint")
|
||||
.noundo()
|
||||
.doc_only()
|
||||
@@ -91,6 +99,16 @@ fn redo(s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
Ok(json!({"redone": label}))
|
||||
}
|
||||
|
||||
const REPEAT_CONTRACT: crate::schema::TypedContract<crate::schema::edit::RepeatParams> = crate::schema::TypedContract::new();
|
||||
|
||||
/// Repeat Last Command (#7077) starts a tool, which only the app has: it starts the last one in
|
||||
/// `SolveApp::start` and never reaches this. A script runs the command it wants itself.
|
||||
fn repeat(_s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
Err(EngineError::Other(
|
||||
"edit.repeat starts the last tool or dialog again in the app (its key, the canvas menu or command search); there is no tool to start here: run that command itself".into(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Put the session at `snap`; returns where it was, under the same label.
|
||||
fn go_to(s: &mut Session, snap: Snapshot) -> Snapshot {
|
||||
let was = Snapshot {
|
||||
|
||||
@@ -40,6 +40,20 @@ fn roll_to_takes_a_number_or_end_and_refuses_anything_else() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7077: Repeat Last Command is a command (its key can change, command search finds it), but
|
||||
/// only the app has a tool to start, so a script's call is refused and changes nothing.
|
||||
#[test]
|
||||
fn repeat_is_refused_outside_the_app_and_changes_nothing() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 10}));
|
||||
let (doc, undo) = (s.doc.to_json(), s.undo.len());
|
||||
let e = s.execute("edit.repeat", &json!({})).unwrap_err().to_string();
|
||||
assert!(e.contains("in the app"), "{e}");
|
||||
assert_eq!((s.doc.to_json(), s.undo.len()), (doc, undo));
|
||||
let spec = crate::find_command("edit.repeat").unwrap();
|
||||
assert_eq!((spec.shortcut, spec.tab, spec.undoable), (Some("Shift+R"), "", false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn g2_fillet_survives_edit_undo_and_reopen() {
|
||||
use solidcraft_doc::{Document, FeatureKind, FilletStyle};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//! Contracts and result types for the commands in `cmd/edit.rs`.
|
||||
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// `edit.repeat` takes no parameters: it starts the last tool with its defaults.
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct RepeatParams {}
|
||||
|
||||
/// What `edit.repeat` returns: nothing. Called through the engine it is always refused, since
|
||||
/// only the app has a tool to start.
|
||||
#[derive(Debug, Serialize, JsonSchema)]
|
||||
pub struct RepeatResult {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::RepeatParams;
|
||||
use crate::schema::input_schema_for;
|
||||
use crate::schema::tests::assert_keys;
|
||||
|
||||
#[test]
|
||||
fn schemas_and_the_key_check_agree() {
|
||||
assert_keys(input_schema_for::<RepeatParams>(), &[]);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ mod coverage_tests;
|
||||
mod tests;
|
||||
|
||||
// The contracts, by command file.
|
||||
pub mod edit;
|
||||
pub mod features;
|
||||
pub mod inspect;
|
||||
|
||||
|
||||
@@ -325,9 +325,10 @@ 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 key = crate::keymap::display_for(app, "edit.repeat").unwrap_or_default();
|
||||
let repeat = match &app.last_command {
|
||||
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),
|
||||
Some((_, label)) => act("ui.repeat", &format!("Repeat {label}"), "redo").key(&key),
|
||||
None => act("ui.repeat", "Repeat", "redo").key(&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() {
|
||||
@@ -500,7 +501,8 @@ 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").key(crate::keymap::REPEAT_KEY));
|
||||
let key = crate::keymap::display_for(app, "edit.repeat").unwrap_or_default();
|
||||
v.push(act("ui.repeat", &format!("Repeat {label}"), "redo").key(&key));
|
||||
v.push(Item::sep());
|
||||
}
|
||||
// Everything under the cursor, for what lies beneath something else.
|
||||
|
||||
@@ -11,12 +11,8 @@ use solidcraft_engine::{CommandSpec, 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",
|
||||
@@ -1072,8 +1068,7 @@ mod tests {
|
||||
}
|
||||
|
||||
/// #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.
|
||||
/// down), R alone is still the rectangle; the menus show the key on Repeat.
|
||||
#[test]
|
||||
fn shift_r_repeats_the_last_tool() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
@@ -1093,9 +1088,60 @@ mod tests {
|
||||
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");
|
||||
assert_eq!(repeat.shortcut, display("Shift+R"));
|
||||
}
|
||||
|
||||
/// #7077: Repeat Last Command is the command `edit.repeat`: Keyboard Shortcuts lists it and
|
||||
/// can give it another key (the old one then does nothing, and the menus show the new one),
|
||||
/// another command takes its key only on request, and command search finds and starts it.
|
||||
/// Typing Shift+R into a field is text, not Repeat.
|
||||
#[test]
|
||||
fn repeat_last_command_is_a_command_with_a_key_that_can_change() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.frames(2);
|
||||
assert_eq!(effective(&h.app, "edit.repeat").as_deref(), Some("Shift+R"));
|
||||
assert_eq!(commands_for(&h.app, "Shift+R"), ["edit.repeat"], "no other default uses Shift+R");
|
||||
assert!(bind(&mut h.app, "solid.extrude", "Shift+R", false).unwrap_err().contains("Repeat Last Command"));
|
||||
// Nothing was started yet: Repeat says so and starts nothing.
|
||||
h.step(&json!({"key": "R", "shift": true})).unwrap();
|
||||
assert!(h.app.dialog.is_none() && h.app.tool.is_none());
|
||||
assert_eq!(h.app.status.as_ref().map(|s| s.0.as_str()), Some(h.app.tr("ui.repeat_nothing")));
|
||||
h.step(&json!({"start": "solid.box"})).unwrap();
|
||||
h.frames(2);
|
||||
assert!(h.app.dialog.is_some(), "Box opens its dialog");
|
||||
crate::dialogs::cancel(&mut h.app);
|
||||
h.frames(1);
|
||||
assert!(h.app.dialog.is_none());
|
||||
// Another key for Repeat: Shift+R is free again, Alt+Shift+R starts Box's dialog again.
|
||||
bind(&mut h.app, "edit.repeat", "Alt+Shift+R", false).unwrap();
|
||||
h.step(&json!({"key": "R", "shift": true})).unwrap();
|
||||
h.frames(1);
|
||||
assert!(h.app.dialog.is_none(), "the old key no longer repeats");
|
||||
h.step(&json!({"key": "R", "shift": true, "alt": true})).unwrap();
|
||||
h.frames(2);
|
||||
assert_eq!(h.app.dialog.as_ref().and_then(|d| d.command()), Some("solid.box"), "the new key repeats");
|
||||
let repeat = crate::context_menu::radial_items(&h.app).into_iter().find(|i| i.id == "ui.repeat").unwrap();
|
||||
assert_eq!(repeat.shortcut, display("Alt+Shift+R"));
|
||||
crate::dialogs::cancel(&mut h.app);
|
||||
reset(&mut h.app, Some("edit.repeat"));
|
||||
// Command search lists it, and choosing it starts the last command again.
|
||||
assert_eq!(crate::shortcut_box::search(&h.app, "repeat last").first().map(|r| r.0), Some("edit.repeat"));
|
||||
h.call("ui.palette", json!({"text": "repeat last"}));
|
||||
h.frames(3);
|
||||
h.step(&json!({"key": "Enter"})).unwrap();
|
||||
h.frames(2);
|
||||
assert!(!h.app.ui.palette_open);
|
||||
assert_eq!(h.app.dialog.as_ref().and_then(|d| d.command()), Some("solid.box"), "chosen in command search");
|
||||
assert_eq!(h.app.last_command.as_ref().map(|c| c.0.as_str()), Some("solid.box"), "Repeat is never what is repeated");
|
||||
crate::dialogs::cancel(&mut h.app);
|
||||
h.frames(1);
|
||||
// While command search's field takes the keyboard, Shift+R is a letter typed there.
|
||||
h.call("ui.palette", json!({}));
|
||||
h.frames(3);
|
||||
h.step(&json!({"key": "R", "shift": true})).unwrap();
|
||||
h.frames(1);
|
||||
assert!(h.app.ui.palette_open && h.app.dialog.is_none(), "typing in a field never repeats");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1136,10 +1136,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.
|
||||
/// Start the last tool or dialog started again, with its defaults (Repeat in the menus,
|
||||
/// the `edit.repeat` command and its key, Shift+R by default; #3045, #7077). `false` when
|
||||
/// none was started yet: the status line says so.
|
||||
pub fn repeat_last(&mut self) -> bool {
|
||||
let Some((id, _)) = self.last_command.clone() else { return false };
|
||||
let Some((id, _)) = self.last_command.clone() else {
|
||||
self.set_status(self.tr("ui.repeat_nothing").to_string(), false);
|
||||
return false;
|
||||
};
|
||||
self.start(&id);
|
||||
true
|
||||
}
|
||||
@@ -1170,6 +1174,11 @@ impl SolveApp {
|
||||
if self.file_load.busy() || self.file_picker.is_some() {
|
||||
return;
|
||||
}
|
||||
// Repeat Last Command starts the tool it names; it is never the one repeated itself.
|
||||
if id == "edit.repeat" {
|
||||
self.repeat_last();
|
||||
return;
|
||||
}
|
||||
// Front … Isometric (Ctrl+1…7 by default) turn the view as the view cube's faces do. The
|
||||
// flat pattern is a 2D page: it has no other side to turn to.
|
||||
if solidcraft_engine::standard_view(id).is_some() {
|
||||
|
||||
@@ -2163,9 +2163,6 @@ 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