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.
This commit is contained in:
dotCooCoo
2026-11-17 19:42:04 -08:00
parent 612f965679
commit 4b04d3e905
2 changed files with 28 additions and 0 deletions
+5
View File
@@ -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 {
+23
View File
@@ -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]