diff --git a/crates/ui-egui/src/panels/library_panel.rs b/crates/ui-egui/src/panels/library_panel.rs index 6ef14648e..2c167e35a 100644 --- a/crates/ui-egui/src/panels/library_panel.rs +++ b/crates/ui-egui/src/panels/library_panel.rs @@ -244,9 +244,17 @@ fn missing_file(app: &VectorcraftApp, k: Kind, id: &str) -> Option { (k.name)(app, id).is_none().then(|| s.path.clone().unwrap_or_else(|| id.to_string())) } -/// The name of missing library `id` of `k` ([`missing_file`]): its file's name without the extension. +/// The file of library `id` of `k` when its panel is open and the library can't be found, +/// Persistent or not (a panel whose Persistent a command turned off stays open until [`tidy`]). +fn open_missing_file(app: &VectorcraftApp, k: Kind, id: &str) -> Option { + let s = settings(&app.ui, k.kind, id).filter(|_| is_open(&app.ui, &panel_id(k.kind, id)))?; + (k.name)(app, id).is_none().then(|| s.path.clone().unwrap_or_else(|| id.to_string())) +} + +/// The name of missing library `id` of `k` ([`missing_file`], or [`open_missing_file`]): its file's +/// name without the extension. fn missing_name(app: &VectorcraftApp, k: Kind, id: &str) -> Option { - let file = missing_file(app, k, id)?; + let file = missing_file(app, k, id).or_else(|| open_missing_file(app, k, id))?; Some(std::path::Path::new(&file).file_stem().map_or_else(|| file.clone(), |s| s.to_string_lossy().into_owned())) } @@ -393,9 +401,10 @@ pub(crate) fn library_name<'a>(id: &str, name: &'a str) -> &'a str { } /// The opener of library `K`'s libraries (`window.swatchLibrary {library}`): open library `library` -/// (an id or a name, or the id of a missing library's persistent panel, [`missing_file`]) in its -/// own panel, floating, or bring its panel forward when it is open; `null` closes every panel of -/// `K`'s libraries. → {open, panel, name, count} (a missing library: its [`missing_name`], count 0) +/// (an id or a name, or the id of a missing library's persistent or open panel, [`missing_name`]) +/// in its own panel, floating, or bring its panel forward when it is open; `null` closes every +/// panel of `K`'s libraries. → {open, panel, name, count} (a missing library: its +/// [`missing_name`], count 0) pub(crate) fn open_command(app: &mut VectorcraftApp, p: &Value) -> Result { let Some(key) = p.get("library").filter(|v| !v.is_null()) else { for panel in open_panels(&app.ui).into_iter().filter(|p| parse(p).is_some_and(|(k, _)| k.kind == K::KIND)) { @@ -488,8 +497,8 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result Result