diff --git a/src/app/commands/draw.rs b/src/app/commands/draw.rs index c51425fc7..cd0655e1c 100644 --- a/src/app/commands/draw.rs +++ b/src/app/commands/draw.rs @@ -2006,7 +2006,13 @@ impl OpenCADStudio { ) }) .collect::>(); - let target = (selected.len() == 1).then_some(selected[0]); + // `then_some` evaluates its argument eagerly: indexing an empty + // selection here crashed the app when SHELL was started with + // nothing selected. + let target = match selected.as_slice() { + [handle] => Some(*handle), + _ => None, + }; let new_cmd = if cmd == "SHELL" { ShellCommand::direct(target) } else {