forked from 1b-agent/opencadstudio-upstream
fix(command): drain pending pause tokens on viewport click and coordinate input
This commit is contained in:
1 parent
c96de124b6
commit
bc6ad1a5fe
2 files changed
+16
-13
No files matched your search
@@ -556,15 +556,9 @@ impl OpenCADStudio {
|
||||
if is_escape {
|
||||
self.tabs[i].pending_pause_tokens = None;
|
||||
}
|
||||
let task = match result {
|
||||
match result {
|
||||
Some(r) => self.apply_cmd_result(r),
|
||||
None => Task::none(),
|
||||
};
|
||||
if !is_escape && self.tabs[i].active_cmd.is_some() && self.tabs[i].pending_pause_tokens.is_some() {
|
||||
let drain_task = self.drain_pending_pause_tokens(i);
|
||||
Task::batch([task, drain_task])
|
||||
} else {
|
||||
task
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1075,8 +1069,14 @@ impl OpenCADStudio {
|
||||
self.tabs[i].scene.set_hover_highlight(None);
|
||||
self.command_line.set_step_options(Vec::new());
|
||||
self.restore_add_selected_defaults();
|
||||
self.tabs[i].pending_pause_tokens = None;
|
||||
}
|
||||
if self.tabs[i].active_cmd.is_some() && self.tabs[i].pending_pause_tokens.is_some() {
|
||||
let drain_task = self.drain_pending_pause_tokens(i);
|
||||
Task::batch([task, drain_task])
|
||||
} else {
|
||||
task
|
||||
}
|
||||
task
|
||||
}
|
||||
|
||||
/// Resolve the cell under `click` on table `handle` (or any table in the drawing
|
||||
|
||||
@@ -1178,11 +1178,14 @@ mod tests {
|
||||
host.app.tabs[0].pending_pause_tokens,
|
||||
Some(vec!["ENTER".to_string()])
|
||||
);
|
||||
// User clicks second point in viewport
|
||||
let _ = host
|
||||
.app
|
||||
.feed_command(crate::command::StepInput::Point(glam::DVec3::new(30.0, 30.0, 0.0)));
|
||||
// Draining should have executed ENTER and completed LINE
|
||||
// User clicks second point in viewport (which calls on_point + apply_cmd_result)
|
||||
let r = host.app.tabs[0]
|
||||
.active_cmd
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.on_point(glam::DVec3::new(30.0, 30.0, 0.0));
|
||||
let _ = host.app.apply_cmd_result(r);
|
||||
// Draining in apply_cmd_result should have executed ENTER and completed LINE
|
||||
assert!(host.app.tabs[0].active_cmd.is_none());
|
||||
assert_eq!(host.document().entities().count(), 3);
|
||||
|
||||
|
||||
Reference in new issue
Block a user