forked from 1b-agent/opencadstudio-upstream
SHELL: do not index an empty selection when the command starts
`bool::then_some` evaluates its argument eagerly, so starting SHELL or SOLIDEDIT with nothing selected indexed an empty vector and aborted the application. The single-solid target now comes from a slice match. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
960d51d955
commit
99eadd7609
1 file changed
+7
-1
@@ -2006,7 +2006,13 @@ impl OpenCADStudio {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
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" {
|
let new_cmd = if cmd == "SHELL" {
|
||||||
ShellCommand::direct(target)
|
ShellCommand::direct(target)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user