diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 40ec47f7f5..65f7fae972 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -356,7 +356,7 @@ fn unreadable_library_ids(app: &VectorcraftApp) -> Hiding { .collect(); // The longest first, so that an id that begins another one does not replace part of it. hidden.sort_by_key(|(id, _)| std::cmp::Reverse(id.len())); - Hiding { hidden, readable: readable_ids } + Hiding { hidden, readable: readable_ids, sent: Vec::new() } } /// What a reply hides ([`hide_library_ids`]). @@ -368,6 +368,9 @@ struct Hiding { /// The other loaded library ids the UI state and the session hold: an occurrence of a hidden id or /// path that begins one of them stays ([`begins_known_id`]). readable: std::collections::BTreeSet, + /// The paths outside the read roots that the request sent ([`sent_paths`]), each as a hidden + /// library id with the id shown. They are matched after the hidden libraries. + sent: Vec<(String, String)>, } impl Hiding { @@ -387,16 +390,26 @@ impl Hiding { self.hidden.sort_by_key(|(id, _)| std::cmp::Reverse(id.len())); } - /// Adds the hidden ids of `pairs`, each with the id shown, in place of each id this one holds for - /// the same path: written with either separator, and in any case of ASCII letters with `fold`. + /// Adds the sent paths of `pairs`, each as a hidden id with the id shown. A hidden id this one holds + /// for the same path (written with either separator, relative or as the absolute path it reads as + /// ([`absolute_form`]), and in any case of ASCII letters with `fold`) is shown as the sent path is. fn set_hidden(&mut self, pairs: Vec<(String, String)>, fold: bool) { let key = |id: &str| { - let id = id.replace('\\', "/"); + let path = id.strip_prefix("loaded/").unwrap_or(id); + let id = absolute_form(path).unwrap_or_else(|| path.to_string()).replace('\\', "/"); if fold { id.to_ascii_lowercase() } else { id } }; let sent: Vec = pairs.iter().map(|(id, _)| key(id)).collect(); - self.hidden.retain(|(id, _)| !sent.contains(&key(id))); - self.add_hidden(pairs); + for (id, shown) in &mut self.hidden { + if let Some(at) = sent.iter().position(|k| *k == key(id)) { + shown.clone_from(&pairs[at].1); + } + } + for pair in pairs { + if !self.sent.iter().any(|(id, _)| *id == pair.0) { + self.sent.push(pair); + } + } } } @@ -477,31 +490,48 @@ fn collect_library_panel_ids(v: &Value, ids: &mut std::collections::BTreeSet