fix(selection): keep active selection on empty box/lasso

An empty box or lasso drag called deselect_all, discarding a selection
the user may have built up over several picks. Drop the empty-clear from
the lasso and two-click box paths so a stray empty drag leaves the
selection untouched; Esc remains the deliberate clear. (issue #83)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-12 14:07:57 +03:00
commit 9de2760dee

View file

@ -3396,14 +3396,13 @@ impl OpenCADStudio {
// Selection filter: keep only allowed types.
handles.retain(|&h| self.tabs[i].scene.passes_selection_filter(h));
// Accumulate like the box path (issue #83): plain
// lasso adds, Shift+lasso removes, an empty lasso
// clears.
// lasso adds, Shift+lasso removes. An empty lasso
// leaves the current selection untouched so a stray
// drag never discards hard-won picks.
if self.shift_down {
for h in &handles {
self.tabs[i].scene.deselect_entity(*h);
}
} else if handles.is_empty() {
self.tabs[i].scene.deselect_all();
} else {
for h in &handles {
self.tabs[i].scene.select_entity(*h, false);
@ -3534,14 +3533,12 @@ impl OpenCADStudio {
handles.retain(|&h| self.tabs[i].scene.passes_selection_filter(h));
// Accumulate (issue #83): a plain box adds to the
// current selection, Shift+box removes the boxed
// entities, and an empty box clears (the two-click
// analogue of clicking empty space).
// entities. An empty box leaves the selection alone
// so an accidental empty drag never discards it.
if self.shift_down {
for h in &handles {
self.tabs[i].scene.deselect_entity(*h);
}
} else if handles.is_empty() {
self.tabs[i].scene.deselect_all();
} else {
for h in &handles {
self.tabs[i].scene.select_entity(*h, false);