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 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-28 21:51:38 +00:00
1 parent 74cd72a551
commit 857aba8dc4
2 files changed
+36 -6

No files matched your search

+13 -6
View File
@@ -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::<Leads>().recent = lead;
}
/// `row` with its age or note, when it has one, as its next trailing text.
fn with_detail(row: ListRow<'_>, detail: Option<String>) -> ListRow<'_> {
match detail {
Some(detail) => row.trailing(detail),
None => row,
}
}
+23
View File
@@ -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<Target> = 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.