From 4b04d3e905e77e42e300c01a2cb050a26f2b5538 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 19:42:04 -0800 Subject: [PATCH] Links: the panel opened from the Control bar label reads its list again The panel keeps its list for two seconds before it looks at the files again. When an image's file changed in that time, for example a deleted file under Show Missing, the label opened the panel on the old list, which lacked the image's row, and the list did not scroll to it. Opening the panel from the label now reads the list again. --- crates/ui-egui/src/panels/links.rs | 5 +++++ crates/ui-egui/src/panels/tests_links.rs | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/crates/ui-egui/src/panels/links.rs b/crates/ui-egui/src/panels/links.rs index 7eaf6da8c2..7951595ba0 100644 --- a/crates/ui-egui/src/panels/links.rs +++ b/crates/ui-egui/src/panels/links.rs @@ -96,6 +96,11 @@ pub(crate) fn show_selected_image(app: &mut VectorcraftApp, ctx: &egui::Context) _ => false, }; set_pstate(ctx, "links-scroll-to", first); + // The list drawn next is read after this request, so a row a file change has just brought + // into the Show filter is there to scroll to. + let mut c: Cache = pstate(ctx, "links-cache"); + c.at = f64::NEG_INFINITY; + set_pstate(ctx, "links-cache", c); set_options(ctx, |o| { o.info = true; if hidden { diff --git a/crates/ui-egui/src/panels/tests_links.rs b/crates/ui-egui/src/panels/tests_links.rs index fbee40fbc7..f7e067aeed 100644 --- a/crates/ui-egui/src/panels/tests_links.rs +++ b/crates/ui-egui/src/panels/tests_links.rs @@ -219,6 +219,29 @@ fn opening_the_panel_on_the_selected_image_scrolls_to_its_row() { assert_eq!(drawn(&mut app, 6.0), before + 1, "the row scrolled into view"); } +/// Opening the panel on the selected image draws a list read after the request, so a row that a +/// file change brought into the Show filter since the list was last read is there to scroll to. +#[test] +fn opening_the_panel_on_the_selected_image_reads_the_list_again() { + let dir = Folder::new("show-selected-fresh"); + let (mut app, linked, _) = app(&dir); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + // How many times the linked image's name is drawn: its row, and Link Info. + let drawn = |app: &mut VectorcraftApp, time: f64| { + let raw = egui::RawInput { time: Some(time), ..Default::default() }; + let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show); + texts.iter().filter(|(t, _)| t == "linked.png").count() + }; + app.run("select.set", json!({"ids": [linked]})).unwrap(); + click_menu_item(&mut app, &ctx, "Show Missing", 1.0); + assert_eq!(drawn(&mut app, 2.0), 1, "Link Info only: nothing is missing yet"); + std::fs::remove_file(dir.0.join("linked.png")).unwrap(); + // Within the time the panel keeps its list before it looks at the files again. + super::links::show_selected_image(&mut app, &ctx); + assert_eq!(drawn(&mut app, 2.1), 2, "the missing image's row and its Link Info are drawn"); +} + /// Copy Info copies the file names of the selected links, or of `ids` in the order given, one per /// line; it is off with nothing selected, and a bad `ids` leaves the clipboard as it was. #[test]