From 857aba8dc4cb623fc37207323c81e8d41bdff565 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 28 Nov 2026 21:51:38 +0000 Subject: [PATCH] recent list: an always-shown remove part keeps the end column past a row's age or note Co-Authored-By: Claude Opus 5.5 --- crates/ui-shell/src/shell/recent_list.rs | 19 +++++++++++++------ crates/ui-shell/tests/it/shell/start.rs | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/crates/ui-shell/src/shell/recent_list.rs b/crates/ui-shell/src/shell/recent_list.rs index 058be0d489..9fb7c58f47 100644 --- a/crates/ui-shell/src/shell/recent_list.rs +++ b/crates/ui-shell/src/shell/recent_list.rs @@ -252,15 +252,14 @@ pub(super) fn recent_body( .show_items(ui, &source, &mut |path, _| { let Some(file) = file_of(path) else { return ListRow::new(Label::Empty) }; let row = ListRow::new(Label::from(file.name.clone())).detail(folder_of(&file.path)).tooltip(file.path.display().to_string()); - let row = match page.recent_detail(file) { - Some(age) => row.trailing(age), - None => row, - }; + let detail = page.recent_detail(file); let (face, name) = (TrailingFace::Icon(IconSpec::svg(IconId::new("close"))), words.remove_recent.fill(&[("name", file.name.as_str())])); + // The first trailing item is the outermost: an always-shown remove part comes first, so every row's + // remove keeps the end column and a row's age or note stands before it. let row = match page.remove { - RecentRemove::Revealed => row.trailing_part_revealed(REMOVE, face, name), - RecentRemove::Always => row.trailing_part(REMOVE, face, name), + RecentRemove::Revealed => with_detail(row, detail).trailing_part_revealed(REMOVE, face, name), + RecentRemove::Always => with_detail(row.trailing_part(REMOVE, face, name), detail), }; match page.thumbnails { Some((thumbnails, source)) => { @@ -301,3 +300,11 @@ pub(super) fn recent_body( } cx.keep::().recent = lead; } + +/// `row` with its age or note, when it has one, as its next trailing text. +fn with_detail(row: ListRow<'_>, detail: Option) -> ListRow<'_> { + match detail { + Some(detail) => row.trailing(detail), + None => row, + } +} diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index e242dc6cfe..5d8dcf7ac3 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -235,6 +235,29 @@ fn a_list_that_always_shows_remove_offers_it_on_every_row_at_rest() { ); } +/// A list that always shows remove keeps every row's remove part in one end column: a row with a note ("(missing)") +/// shows the note before its remove part, not between the part and the row's end. +#[trial] +fn an_always_shown_remove_keeps_one_end_column_past_a_rows_note() { + let files = vec![RecentFile::new("/tmp/work/Poster.psd", "Poster.psd").note("(missing)"), RecentFile::new("/tmp/work/Flyer.psd", "Flyer.psd")]; + let mut fixture = Fixture::new(move |ui| { + let _ = RecentList::new(&files).remove(RecentRemove::Always).show(ui); + }); + fixture.room(egui::Vec2::new(700.0, 500.0)); + fixture.settle(); + let removes: Vec = fixture + .by_role(Role::BUTTON) + .into_iter() + .filter(|button| fixture.tree().name_of(button.node).is_some_and(|name| name.starts_with("Remove"))) + .collect(); + let of = |file: &str| { + let row = recent_row(&fixture, file).expect("the row shows"); + removes.iter().find(|button| row.rect.contains(button.center())).expect("the row has its remove part").rect + }; + let (noted, plain) = (of("Poster.psd"), of("Flyer.psd")); + assert!((noted.center().x - plain.center().x).abs() < 0.5, "both remove parts share the end column: {noted:?} and {plain:?}"); +} + /// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key (off /// macOS, which has none) and Shift+F10 open it from the focused card. The menu is told by "Clear Recent Files", which only the menu has: the /// card's hover action carries "Remove from Recent" too.