forked from 1b-agent/opencadstudio-upstream
Merge pull request #1498 from yztink/fix/repeat-plugin-commands
fix(commands): record last_cmd on plugin dispatch to repeat on Enter
This commit is contained in:
commit
15ab97c9e2
2 files changed
+31
-2
No files matched your search
@@ -731,6 +731,8 @@ impl OpenCADStudio {
|
||||
// (`LINE`), so the full line is not a plugin command and falls through to
|
||||
// the first-word + fed-tokens path below. (#162)
|
||||
if !self.suppress_plugin_dispatch && crate::plugin::try_dispatch(self, i, cmd) {
|
||||
self.tabs[i].last_cmd = Some(cmd.to_string());
|
||||
self.command_line.record_recent(cmd);
|
||||
let toks: Vec<String> = tokens.iter().map(|s| s.to_string()).collect();
|
||||
return self.finish_active_command(&toks, finish);
|
||||
}
|
||||
|
||||
+29
-2
@@ -197,11 +197,15 @@ impl OpenCADStudio {
|
||||
// tool was a one-shot and we must turn the ribbon highlight off here —
|
||||
// normally apply_cmd_result does that, but plugin dispatch can return
|
||||
// without producing a CmdResult.
|
||||
self.tabs[i].last_cmd = Some(cmd.to_string());
|
||||
self.command_line.record_recent(cmd);
|
||||
if self.tabs[i].active_cmd.is_none() {
|
||||
self.ribbon.deactivate_tool();
|
||||
return Task::none();
|
||||
} else {
|
||||
self.sync_dyn_fields();
|
||||
return self.focus_cmd_input();
|
||||
}
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
// Command families are dispatched in source order (see
|
||||
@@ -822,7 +826,7 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
|
||||
#[cfg(test)]
|
||||
mod marquee_cancel_tests {
|
||||
use crate::app::{GripPendingValue, OpenCADStudio};
|
||||
use crate::app::{GripPendingValue, Message, OpenCADStudio};
|
||||
use crate::scene::model::object::GripMenuAction;
|
||||
use crate::scene::pick::grip::GripEdit;
|
||||
use codec::Handle;
|
||||
@@ -968,4 +972,27 @@ mod marquee_cancel_tests {
|
||||
Some("LINE")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_finalize_repeats_last_cmd() {
|
||||
let mut app = fresh();
|
||||
let i = app.active_tab;
|
||||
assert_eq!(app.tabs[i].last_cmd, None);
|
||||
|
||||
// Run LINE command
|
||||
let _ = app.dispatch_command("LINE");
|
||||
assert_eq!(app.tabs[i].last_cmd.as_deref(), Some("LINE"));
|
||||
|
||||
// Cancel LINE with Escape
|
||||
let _ = app.update(Message::CommandEscape);
|
||||
assert!(app.tabs[i].active_cmd.is_none());
|
||||
assert_eq!(app.tabs[i].last_cmd.as_deref(), Some("LINE"));
|
||||
|
||||
// Press Enter (CommandFinalize) on empty command line repeats LINE
|
||||
let _ = app.update(Message::CommandFinalize);
|
||||
assert_eq!(
|
||||
app.tabs[i].active_cmd.as_deref().map(|cmd| cmd.name()),
|
||||
Some("LINE")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user