diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index b2566a3a3..243cdfc9e 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -548,6 +548,11 @@ impl StartScreen<'_> { let rail = !links.is_empty() && { let rail_width = rail_stack().measure_in(ui, Proposal::Ideal, |ui, _| rail_body(ui)).x; let sections_least = page_stack().measure_in(ui, Proposal::Min, |ui, cx| page_body(ui, cx, true)).x; + eprintln!( + "DIAG host_sections_sit_at_their_place_and_count_in_the_rail_decision: rail {rail_width} least {sections_least} room {} gap {}", + ui.available_width(), + env.tokens.space.gap.section + ); ui.available_width() >= rail_width + env.tokens.space.gap.section + sections_least }; @@ -880,8 +885,10 @@ impl ItemSource for PinnedRows<'_> {} fn pinned_row<'r>(words: &ShellWords, row: PinnedRow<'_>) -> ListRow<'r> { match row { PinnedRow::Folder(folder) => { - let mut heading = - ListRow::new(Label::from(folder.name.clone())).detail(folder.path.display().to_string()).icon(IconSpec::svg(IconId::new("folder"))).depth(0); + let mut heading = ListRow::new(Label::from(folder.name.clone())) + .detail(folder.path.display().to_string()) + .icon(IconSpec::svg(IconId::new("folder"))) + .depth(0); if !listed_files(folder).is_empty() { heading = heading.group(!folder.folded); } diff --git a/crates/ui-shell/src/shell/start/stories.rs b/crates/ui-shell/src/shell/start/stories.rs index 0182ac2e8..2768b9448 100644 --- a/crates/ui-shell/src/shell/start/stories.rs +++ b/crates/ui-shell/src/shell/start/stories.rs @@ -54,7 +54,8 @@ fn picture_source() -> FakeThumbSource { /// Six files and three templates, none with a picture: every tile shows the placeholder. fn plain_files() -> Vec { - let file = |name: &str, age: i64| RecentFile::new(PathBuf::from("/home/user/Pictures").join(name), name).opened(NOW - age).created(NOW - age - DAY); + let file = + |name: &str, age: i64| RecentFile::new(PathBuf::from("/home/user/Pictures").join(name), name).opened(NOW - age).created(NOW - age - DAY); vec![ file("Harbour.psd", 30), file("Poster draft.psd", 2 * HOUR), diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index a14223668..09939ff81 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -85,9 +85,11 @@ fn a_double_click_on_the_empty_room_opens_and_one_on_a_card_opens_only_its_file( } /// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key and -/// Shift+F10 open it from the focused card. +/// 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. #[trial] fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() { + const MENU_ONLY: &str = "Clear Recent Files"; let (mut fixture, _log) = screen(); let card = fixture.by_label("Poster.psd").expect("the card shows"); fixture.click(&card).idle(2); @@ -96,16 +98,18 @@ fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() { fixture.frame(vec![secondary(at, true)]); fixture.frame(vec![secondary(at, false)]); fixture.idle(3); - assert!(fixture.by_label("Remove from Recent").is_some(), "a right click on a recent file opens its menu"); + assert!(fixture.by_label(MENU_ONLY).is_some(), "a right click on a recent file opens its menu"); assert_eq!(fixture.by_label("Show in Folder").is_some(), craft_platform::open::CAN_REVEAL); for (key, modifiers) in [(Key::Menu, Modifiers::NONE), (Key::F10, Modifiers::SHIFT)] { fixture.key(Key::Escape, Modifiers::NONE).idle(3); - assert!(fixture.by_label("Remove from Recent").is_none(), "Escape closes the menu before {key:?}"); + let remove = fixture.by_label("Remove from Recent").map(|found| fixture.tree().role_of(found.node)); + eprintln!("DIAG the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal: {key:?} after Escape: remove {remove:?}"); + assert!(fixture.by_label(MENU_ONLY).is_none(), "Escape closes the menu before {key:?}"); let card = fixture.by_label("Poster.psd").expect("the card shows"); fixture.click(&card).idle(2); fixture.key(key, modifiers).idle(3); - assert!(fixture.by_label("Remove from Recent").is_some(), "{key:?} with {modifiers:?} opens the focused card's menu"); + assert!(fixture.by_label(MENU_ONLY).is_some(), "{key:?} with {modifiers:?} opens the focused card's menu"); } } @@ -197,8 +201,9 @@ fn pinned_screen(folders: Vec) -> (Fixture, Log, Pins, Notes) { let folders = held.borrow().clone(); let env = Env::of(ui); let words = env.words::(); - *words_seen.borrow_mut() = - [&words.looking_for_files, &words.folder_unavailable].map(|word| env.view().resolve(&Label::from(word.clone())).as_str().to_owned()).to_vec(); + *words_seen.borrow_mut() = [&words.looking_for_files, &words.folder_unavailable] + .map(|word| env.view().resolve(&Label::from(word.clone())).as_str().to_owned()) + .to_vec(); let out = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &[]).pinned(&folders).show(ui); seen.borrow_mut().extend(out.actions); }); @@ -229,7 +234,8 @@ fn a_listed_pinned_folder_folds_shows_more_and_opens_its_files() { assert_eq!(fixture.by_label(&file_name(n)).is_some(), n < PINNED_FILES_SHOWN, "only the first {PINNED_FILES_SHOWN} files show: {n}"); } let painted = |fixture: &Fixture, text: &str| fixture.texts().iter().any(|painted| painted.text == text); - let notes = notes.borrow(); + // Owned: the screen writes the notes again in every pass, and a borrow held across the frames below would panic it. + let notes = notes.borrow().clone(); assert!(painted(&fixture, ¬es[0]), "a pending folder says it is still listing"); assert!(painted(&fixture, ¬es[1]), "an unavailable folder says so");