forked from 1b-agent/opencadstudio-upstream
fix(selection): clear selection when an interactive command ends
Editing tools (MOVE, COPY, STRETCH, ROTATE, OFFSET, SCALE, MIRROR) and other interactive commands left their working set selected after they finished, so the next edit silently reused it — confusing especially for copy-producing tools. Drop the selection centrally in apply_cmd_result when a command ends (active_cmd Some->None), excepting Relaunch/Dispatch which hand a deliberate selection to a chained command. Pure-selection commands run without an active command, so their result is preserved. Closes #207 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
d1efa4ea7c
commit
d209e7bbb5
1 file changed
+27
@@ -141,7 +141,34 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies one command result, then — when that result ended the active
|
||||
/// command — drops the selection. Editing tools (MOVE, COPY, ROTATE, …) and
|
||||
/// every other interactive command leave nothing selected once they finish,
|
||||
/// so a follow-up edit doesn't silently reuse the previous working set.
|
||||
///
|
||||
/// `Relaunch`/`Dispatch` are excepted: they end the front-end command only
|
||||
/// to immediately start another and hand it a deliberate selection (the
|
||||
/// pick-first selector relaunching MOVE on the picked set works this way).
|
||||
/// Pure-selection commands (SELECTALL, QSELECT, …) run without an active
|
||||
/// command, so `was_active` is false and their selection is preserved.
|
||||
pub(super) fn apply_cmd_result(&mut self, result: CmdResult) -> Task<Message> {
|
||||
let was_active = self.tabs[self.active_tab].active_cmd.is_some();
|
||||
let preserve_selection =
|
||||
matches!(result, CmdResult::Relaunch(..) | CmdResult::Dispatch(..));
|
||||
let task = self.apply_cmd_result_inner(result);
|
||||
let i = self.active_tab;
|
||||
if was_active
|
||||
&& !preserve_selection
|
||||
&& self.tabs[i].active_cmd.is_none()
|
||||
&& !self.tabs[i].scene.selected.is_empty()
|
||||
{
|
||||
self.tabs[i].scene.deselect_all();
|
||||
self.refresh_properties();
|
||||
}
|
||||
task
|
||||
}
|
||||
|
||||
fn apply_cmd_result_inner(&mut self, result: CmdResult) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
match result {
|
||||
CmdResult::NeedPoint => {
|
||||
|
||||
Reference in new issue
Block a user