From 9a4dd39d3aa303e78bba97084f8f87de902e475e Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Fri, 20 Nov 2026 00:56:55 +0000 Subject: [PATCH] Workspace clippy: fix lints across ui crates and tests --- crates/color-ui/src/ui/picker/stories.rs | 4 ++- crates/color-ui/src/ui/picker_dialog.rs | 8 ++++-- crates/dialogs/src/portal/tests.rs | 5 +--- crates/dialogs/src/ui/chooser.rs | 4 +-- crates/menu/src/keytips.rs | 2 +- crates/menu/src/keytips/stories.rs | 2 +- crates/menu/src/ribbon.rs | 6 ++-- crates/menu/src/ribbon/gallery.rs | 2 +- crates/menu/src/ribbon/gallery/stories.rs | 8 ++++-- crates/menu/src/shortcuts/view/lists.rs | 2 +- crates/menu/tests/it/keytips.rs | 2 +- crates/pages/src/ui/reading.rs | 2 -- crates/print/src/spool.rs | 1 - crates/text/src/ui/ruler/items.rs | 2 +- crates/text/tests/it/paragraph.rs | 7 ++--- crates/text/tests/it/tabs.rs | 4 ++- crates/ui-canvas/src/canvas/stories.rs | 6 ++-- crates/ui-canvas/tests/it/canvas/snap.rs | 10 ++++++- .../src/patterns/form_dialogs/about.rs | 1 - .../src/patterns/form_dialogs/form.rs | 28 +++++++++---------- .../src/patterns/form_dialogs/list_manager.rs | 6 ++-- .../patterns/form_dialogs/sizing/canvas.rs | 1 - .../src/patterns/panels/palette.rs | 4 +-- .../tests/it/form_dialogs/picker.rs | 2 +- crates/ui-shell/src/shell/recent_list.rs | 3 -- crates/ui-shell/tests/it/shell/app_shell.rs | 2 +- crates/ui-widgets/tests/it/buttons.rs | 5 ++-- .../ui-widgets/tests/it/contract/levelled.rs | 2 +- crates/ui-widgets/tests/it/table.rs | 6 ++-- crates/ui-widgets/tests/it/tabs.rs | 4 +-- 30 files changed, 71 insertions(+), 70 deletions(-) diff --git a/crates/color-ui/src/ui/picker/stories.rs b/crates/color-ui/src/ui/picker/stories.rs index 63cbaeb170..5918102c3e 100644 --- a/crates/color-ui/src/ui/picker/stories.rs +++ b/crates/color-ui/src/ui/picker/stories.rs @@ -13,6 +13,8 @@ use super::screen_pick::ScreenPickButton; use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor}; use crate::ui::{AreaMode, ColorPickerDialog, ColorPickerDialogLayout, ColorPickerTab, ColorWarning}; +type StandardColors = (Vec<(Label, Srgba)>, Vec<(Label, Srgba)>); + /// A colour of full brightness and saturation at `hue` (0 to 1). fn hue_color(hue: f32) -> Srgba { let channel = |n: f32| (((hue * 6.0 + n) % 6.0 - 3.0).abs() - 1.0).clamp(0.0, 1.0); @@ -20,7 +22,7 @@ fn hue_color(hue: f32) -> Srgba { } /// The Standard tab's honeycomb of 19 hues and its row of greys. -fn standard_colors() -> (Vec<(Label, Srgba)>, Vec<(Label, Srgba)>) { +fn standard_colors() -> StandardColors { let cells = (0..19).map(|i| (Label::from(format!("Color {}", i + 1)), hue_color(i as f32 / 19.0))).collect(); let greys = (0..8) .map(|i| { diff --git a/crates/color-ui/src/ui/picker_dialog.rs b/crates/color-ui/src/ui/picker_dialog.rs index d8dfe7f1aa..ef24c1dd3f 100644 --- a/crates/color-ui/src/ui/picker_dialog.rs +++ b/crates/color-ui/src/ui/picker_dialog.rs @@ -16,7 +16,7 @@ use craft_host::target::Caps; use craft_settings::Remembered; use craft_theme::{ColorModel, Srgba, builtin_models}; use craft_ui::choice::{SwatchArrangement, SwatchTable}; -use craft_ui::contract::{Bind, CanvasGesture, CollectionEvent, Props as _, Sampler as _, ShowCollection as _, ShowContainer as _}; +use craft_ui::contract::{Bind, CanvasGesture, CollectionEvent, Sampler as _, ShowCollection as _, ShowContainer as _}; use craft_ui::dialog::{ ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id, serde_fields, set_serde_field, }; @@ -37,6 +37,8 @@ use std::sync::Arc; use super::{ColorPicker, ColorPickerLayout, ColorWarning, PickedColor, ScreenPickGesture}; use crate::{AreaMode, CmykModel, not_web_safe, web_safe}; +type StandardColors = (Vec<(Label, Srgba)>, Vec<(Label, Srgba)>); + craft_ui::words! { /// The Color Picker dialog's own words, English by default. The picker body's words are `ColorPickerWords`; OK and /// Cancel are the common words. @@ -170,7 +172,7 @@ pub struct ColorPickerDialog { open: bool, layout: ColorPickerDialogLayout, /// The Standard tab's honeycomb cells and grey row. - standard: Option<(Vec<(Label, Srgba)>, Vec<(Label, Srgba)>)>, + standard: Option, /// The tab the app asked to open on; it wins over the remembered one, once. tab: Option, } @@ -179,7 +181,7 @@ pub struct ColorPickerDialog { struct TabbedBody<'a> { title: &'a Label, words: &'a ColorPickerDialogWords, - standard: Option<&'a (Vec<(Label, Srgba)>, Vec<(Label, Srgba)>)>, + standard: Option<&'a StandardColors>, compare: Option>, } diff --git a/crates/dialogs/src/portal/tests.rs b/crates/dialogs/src/portal/tests.rs index 8ada681e44..d4bfad5bdc 100644 --- a/crates/dialogs/src/portal/tests.rs +++ b/crates/dialogs/src/portal/tests.rs @@ -12,10 +12,7 @@ fn a_portal_answer_falls_back_only_when_it_failed() { assert_eq!(classify(2, quick, false, false, ¬hing), Decision::Retry, "a dialog that closed at once never showed"); assert_eq!(classify(2, slow, false, false, ¬hing), Decision::Cancelled, "Esc in GNOME's dialog is a cancel"); assert_eq!(classify(1, quick, false, false, ¬hing), Decision::Cancelled, "Cancel is never asked again"); - assert!( - matches!(classify(0, slow, false, false, &file), Decision::Saved(saved) if saved.path == PathBuf::from("/s/a.txt")), - "a save names its file" - ); + assert!(matches!(classify(0, slow, false, false, &file), Decision::Saved(saved) if saved.path == *"/s/a.txt"), "a save names its file"); assert_eq!(classify(0, slow, true, false, &file), Decision::Cancelled, "an answer after a queued cancel is a cancel"); assert!(matches!(classify(0, slow, false, true, ¬hing), Decision::Unavailable(_)), "the portal left the bus"); assert!(matches!(classify(3, slow, false, false, &file), Decision::Unavailable(_)), "another code is a failure"); diff --git a/crates/dialogs/src/ui/chooser.rs b/crates/dialogs/src/ui/chooser.rs index f55dbcf922..aace9402af 100644 --- a/crates/dialogs/src/ui/chooser.rs +++ b/crates/dialogs/src/ui/chooser.rs @@ -398,7 +398,7 @@ impl FileChooser { PickKind::Save => (words.save_title.clone(), words.save.clone()), PickKind::Folder => (words.folder_title.clone(), words.choose.clone()), }; - let title = self.request.title.clone().map_or_else(|| title.into(), craft_ui::runtime::env::Label::from); + let title = self.request.title.clone().map_or_else(|| title, craft_ui::runtime::env::Label::from); let mut types: Vec> = self.request.filters.iter().enumerate().map(|(at, filter)| Choice::new(at, filter.name.clone())).collect(); types.push(Choice::new(self.request.filters.len(), words.all_files.clone())); @@ -517,7 +517,7 @@ impl FileChooser { return None; } if let Some(path) = seen.activated { - let Some(entry) = rows.iter().find(|entry| entry.path == path).cloned() else { return None }; + let entry = rows.iter().find(|entry| entry.path == path).cloned()?; if entry.folder { self.navigate(entry.path); return None; diff --git a/crates/menu/src/keytips.rs b/crates/menu/src/keytips.rs index 19ef7e9434..8ed1237aa7 100644 --- a/crates/menu/src/keytips.rs +++ b/crates/menu/src/keytips.rs @@ -323,7 +323,7 @@ impl<'a> Keytips<'a> { .elements .iter() .enumerate() - .find(|(index, element)| element.rect.is_positive() && !taken.contains(&(region, *index)) && matches(*element)) + .find(|(index, element)| element.rect.is_positive() && !taken.contains(&(region, *index)) && matches(element)) .map(|(index, _)| (region, index)) }) } diff --git a/crates/menu/src/keytips/stories.rs b/crates/menu/src/keytips/stories.rs index 872c7d8435..07164dd1b0 100644 --- a/crates/menu/src/keytips/stories.rs +++ b/crates/menu/src/keytips/stories.rs @@ -71,7 +71,7 @@ fn shown(ui: &mut Ui, size: ControlSize, letters: [Option<&'static str>; 5]) -> let controls: Vec> = CONTROLS .iter() .zip(letters) - .map(|((command, label), letters)| KeytipControl { command: CommandRef::from(*command), label: *label, letters }) + .map(|((command, label), letters)| KeytipControl { command: CommandRef::from(*command), label, letters }) .collect(); let output = Keytips::new(true).tabs(&tabs).controls(&controls).places(&places).show(ui); output.response.into() diff --git a/crates/menu/src/ribbon.rs b/crates/menu/src/ribbon.rs index ebefb9092a..8a39658d2d 100644 --- a/crates/menu/src/ribbon.rs +++ b/crates/menu/src/ribbon.rs @@ -35,6 +35,8 @@ use group::BodyHeight; pub use group::RibbonGroup; pub use plan::{GroupWidths, plan}; +type ContextMenuBody<'a> = &'a mut dyn FnMut(&mut Ui, &RibbonMenuRequest, &mut BodyCx<'_>); + craft_ui::words! { /// The words of the ribbon's own controls. struct RibbonWords { @@ -66,7 +68,7 @@ pub struct Ribbon<'a, T: Clone + Eq + Hash + Send + Sync + Debug + 'static> { trailing: &'a [StripEnd<'a>], minimised: Option>, /// The body of the context menu: the rows for the request that opened it. - context_menu: Option<&'a mut dyn FnMut(&mut Ui, &RibbonMenuRequest, &mut BodyCx<'_>)>, + context_menu: Option>, } impl<'a, T: Clone + Eq + Hash + Send + Sync + Debug + 'static> Ribbon<'a, T> { @@ -111,7 +113,7 @@ impl<'a, T: Clone + Eq + Hash + Send + Sync + Debug + 'static> Ribbon<'a, T> { pub fn show(mut self, ui: &mut Ui, mut body: impl FnMut(&mut RibbonRow<'_>, &T)) -> RibbonOutput { let current = self.current(); let minimised = self.minimised.as_mut().and_then(|bind| bind.reborrow().get()).and_then(|value| value.same().copied()).unwrap_or(false); - let id = ui.id().with(self.label.as_str()); + let id = ui.scope_id().with(self.label.as_str()); let tabs = self.tabs; let trailing = self.trailing; let strip_label = self.label.clone(); diff --git a/crates/menu/src/ribbon/gallery.rs b/crates/menu/src/ribbon/gallery.rs index c2a0d7c323..d9c59ede4b 100644 --- a/crates/menu/src/ribbon/gallery.rs +++ b/crates/menu/src/ribbon/gallery.rs @@ -227,7 +227,7 @@ impl<'a> GalleryFace<'a> { fn picture(&self, aspect: ThumbAspect, size: ThumbSize) -> Picture<'a> { let picture = match self { GalleryFace::Image { key, revision, image } => Picture::new(Label::default(), *key, *image).revision(*revision), - GalleryFace::Rendered { key, thumbnails, source } => Picture::rendered(Label::default(), *key, *thumbnails, *source), + GalleryFace::Rendered { key, thumbnails, source } => Picture::rendered(Label::default(), *key, thumbnails, *source), GalleryFace::Paint(paint) => { let paint = *paint; Picture::painter(Label::default(), aspect, move |cx: &ContentPainterCx<'_>, rect: Rect| paint(cx, rect)) diff --git a/crates/menu/src/ribbon/gallery/stories.rs b/crates/menu/src/ribbon/gallery/stories.rs index 68d67f67af..6a32348693 100644 --- a/crates/menu/src/ribbon/gallery/stories.rs +++ b/crates/menu/src/ribbon/gallery/stories.rs @@ -16,6 +16,8 @@ use egui::Ui; use super::{Gallery, GalleryFace, GalleryItem, GalleryMore}; use crate::ribbon::GroupLevel; +type Paint = Box; + /// How many tiles every story's gallery holds: more than a row at either level. const COUNT: usize = 10; @@ -95,7 +97,7 @@ fn gallery_compact(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { |set| { set.values.set(GroupLevel::Compact); }, - |ui| pictured(ui), + pictured, ) } @@ -128,12 +130,12 @@ fn gallery_more_open(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { #[story(Gallery<'static, usize>, covers = [], drive = Drive::Never)] fn gallery_painted(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { // Glyph tiles: a disc in the content painter's ink whose size grows with the tile's place. - let paints: Vec> = (0..COUNT) + let paints: Vec = (0..COUNT) .map(|at| { Box::new(move |cx: &craft_ui::primitives::ContentPainterCx, rect: egui::Rect| { let radius = rect.size().min_elem() * (at as f32 + 3.0) / (2.0 * COUNT as f32); cx.data_shapes([egui::Shape::circle_filled(rect.center(), radius, cx.ink())]); - }) as Box + }) as Paint }) .collect(); let items: Vec> = diff --git a/crates/menu/src/shortcuts/view/lists.rs b/crates/menu/src/shortcuts/view/lists.rs index 1531a9cf55..a72210479c 100644 --- a/crates/menu/src/shortcuts/view/lists.rs +++ b/crates/menu/src/shortcuts/view/lists.rs @@ -150,7 +150,7 @@ fn detail(ui: &mut Ui, now: f64, env: &mut Env<'_>, state: &mut DialogState) { Text::new(line).shade(Shade::Muted).show(ui); } // A chord the command already holds is not assigned twice. - let assignable = state.field.as_ref().is_some_and(|field| !env.keymap.bindings(&command).iter().any(|binding| *binding == field.binding)); + let assignable = state.field.as_ref().is_some_and(|field| !env.keymap.bindings(&command).contains(&field.binding)); Row::new().show(ui, |ui, _| { if clicked(&Button::new(words.assign.clone()).id_salt("assign").enabled(assignable).show(ui)) { state.assign_field(env); diff --git a/crates/menu/tests/it/keytips.rs b/crates/menu/tests/it/keytips.rs index b7220a37de..0cd4fa0e5e 100644 --- a/crates/menu/tests/it/keytips.rs +++ b/crates/menu/tests/it/keytips.rs @@ -127,7 +127,7 @@ impl Rig { let tabs = [(Label::from("Home"), "H", tab_id("Home")), (Label::from("Insert"), "N", tab_id("Insert"))]; let controls: Vec> = CONTROLS .iter() - .map(|(command, label, letters)| KeytipControl { command: CommandRef::from(*command), label: *label, letters: *letters }) + .map(|(command, label, letters)| KeytipControl { command: CommandRef::from(*command), label, letters: *letters }) .collect(); let sequences = [("VZ", CommandRef::from(Trial::Zoom)), ("TW", CommandRef::from(Trial::WordCount))]; let output = Keytips::new(true).tabs(&tabs).controls(&controls).sequences(&sequences).places(&places).show(ui); diff --git a/crates/pages/src/ui/reading.rs b/crates/pages/src/ui/reading.rs index 6badc9be54..21fc7a7c15 100644 --- a/crates/pages/src/ui/reading.rs +++ b/crates/pages/src/ui/reading.rs @@ -480,14 +480,12 @@ impl<'a> ReadingNav<'a> { } /// Shows the "n / m" position between the buttons. - #[must_use] pub fn position(mut self, shown: bool) -> Self { self.position = shown; self } /// Adds one trailing button named `label`, reported as [`ReadingNavOutput::action`]. - #[must_use] pub fn action(mut self, label: impl Into) -> Self { self.action = Some(label.into()); self diff --git a/crates/print/src/spool.rs b/crates/print/src/spool.rs index 6fa4588341..6590ffc15f 100644 --- a/crates/print/src/spool.rs +++ b/crates/print/src/spool.rs @@ -178,7 +178,6 @@ pub trait SpoolBackend: Send + Sync { /// Whether the user chooses a printer for a job; false where the platform's own print dialog /// does (the browser). [`Spool::chooses_printer`] answers it. - fn chooses_printer(&self) -> bool { true } diff --git a/crates/text/src/ui/ruler/items.rs b/crates/text/src/ui/ruler/items.rs index 80809f8a16..59d6c34910 100644 --- a/crates/text/src/ui/ruler/items.rs +++ b/crates/text/src/ui/ruler/items.rs @@ -35,7 +35,7 @@ pub(super) fn gap_part(index: usize, edge: GapEdge) -> u64 { /// The gap and edge a part index of [`GAP`] stands for. pub(super) fn gap_of_part(part: u64) -> (usize, GapEdge) { - ((part / 2) as usize, if part % 2 == 0 { GapEdge::End } else { GapEdge::Start }) + ((part / 2) as usize, if part.is_multiple_of(2) { GapEdge::End } else { GapEdge::Start }) } /// A marker or stop on the ruler. diff --git a/crates/text/tests/it/paragraph.rs b/crates/text/tests/it/paragraph.rs index d413903460..bcfd4c4f76 100644 --- a/crates/text/tests/it/paragraph.rs +++ b/crates/text/tests/it/paragraph.rs @@ -15,9 +15,7 @@ fn toggled(fixture: &Fixture, label: &str) -> Option> { #[trial] fn word_paragraph_tabs_leave_mixed_boxes_unset_until_clicked() { - let mut format = ParagraphFormat::default(); - format.breaks = Some(LineBreakOptions::default()); - format.asian = Some(AsianTypography::default()); + let format = ParagraphFormat { breaks: Some(LineBreakOptions::default()), asian: Some(AsianTypography::default()), ..ParagraphFormat::default() }; let dialog = Rc::new(RefCell::new(ParagraphDialog::new(format).word(true).held_ok().tab(ParagraphTab::LineAndPageBreaks))); let shown = dialog.clone(); let mut fixture = Fixture::new(move |ui| { @@ -51,8 +49,7 @@ fn word_paragraph_tabs_leave_mixed_boxes_unset_until_clicked() { #[trial] fn a_mixed_contextual_spacing_box_clicked_is_on_in_the_answer() { const LABEL: &str = "Don't add space between paragraphs of the same style"; - let mut format = ParagraphFormat::default(); - format.contextual_spacing = Some(None); + let format = ParagraphFormat { contextual_spacing: Some(None), ..ParagraphFormat::default() }; let dialog = Rc::new(RefCell::new(ParagraphDialog::new(format).word(true).held_ok())); let shown = dialog.clone(); let mut fixture = Fixture::new(move |ui| { diff --git a/crates/text/tests/it/tabs.rs b/crates/text/tests/it/tabs.rs index bffa2b65ba..b725a2ce71 100644 --- a/crates/text/tests/it/tabs.rs +++ b/crates/text/tests/it/tabs.rs @@ -16,7 +16,9 @@ fn focused<'a>(fixture: &Fixture, labels: &[&'a str]) -> Option<&'a str> { } /// A fixture showing `dialog`, and where the result of a closing OK lands. -fn shown(dialog: TabStopsDialog) -> (Fixture, Rc>, Rc>>) { +type Shown = (Fixture, Rc>, Rc>>); + +fn shown(dialog: TabStopsDialog) -> Shown { let dialog = Rc::new(RefCell::new(dialog)); let result = Rc::new(RefCell::new(None)); let (shown, landed) = (dialog.clone(), result.clone()); diff --git a/crates/ui-canvas/src/canvas/stories.rs b/crates/ui-canvas/src/canvas/stories.rs index 1bdc353355..dc068f2bfd 100644 --- a/crates/ui-canvas/src/canvas/stories.rs +++ b/crates/ui-canvas/src/canvas/stories.rs @@ -120,8 +120,7 @@ fn press_menu_key(fixture: &mut Fixture) { #[story(Canvas, covers = [Default])] fn document_wheel(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let room = stage(ui); - let mut navigation = NavigationOptions::default(); - navigation.wheel = WheelScheme::Document; + let navigation = NavigationOptions { wheel: WheelScheme::Document, ..NavigationOptions::default() }; let view = data.value("view", scrolled_view(room, ui.pixels_per_point())); Canvas::new("Document") .navigation(navigation) @@ -143,8 +142,7 @@ fn scrolled_view(room: Rect, pixels_per_point: f32) -> craft_behavior::CanvasVie #[story(Canvas, covers = [], drive = Drive::Custom(middle_click_centre))] fn middle_autoscroll(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let room = stage(ui); - let mut navigation = NavigationOptions::default(); - navigation.middle_button = MiddleButton::Autoscroll; + let navigation = NavigationOptions { middle_button: MiddleButton::Autoscroll, ..NavigationOptions::default() }; let view = data.value("view", scrolled_view(room, ui.pixels_per_point())); let shown = Canvas::new("Document") .navigation(navigation) diff --git a/crates/ui-canvas/tests/it/canvas/snap.rs b/crates/ui-canvas/tests/it/canvas/snap.rs index 2691042cb9..ece960813d 100644 --- a/crates/ui-canvas/tests/it/canvas/snap.rs +++ b/crates/ui-canvas/tests/it/canvas/snap.rs @@ -109,7 +109,12 @@ fn snap_targets_snap_points_and_boxes_unless_control_suspends() { assert_eq!(snap.apply(Axis::Y, 103.0, Mods::NONE), 100.0); assert_eq!(snapped_with(&mut fixture, Modifiers::CTRL), NEAR, "Ctrl held suspends the tool's snap"); - // With Alt as the suspend key, Alt suspends and Control no longer does, on either OS. + alt_suspends(options); + snap_off(options); +} + +/// With Alt as the suspend key, Alt suspends and Control no longer does, on either OS. +fn alt_suspends(options: SnapOptions) { let mut alt = options; alt.suspend = SnapSuspend::Alt; for os in [Platform::Mac, Platform::Windows] { @@ -132,7 +137,10 @@ fn snap_targets_snap_points_and_boxes_unless_control_suspends() { assert_eq!(snapped_with(&mut fixture, Modifiers::ALT), NEAR, "Alt held suspends the tool's snap on {os:?}"); assert_eq!(snapped_with(&mut fixture, Modifiers::CTRL), Point::new(100.0, 200.0), "Control held snaps the tool on {os:?}"); } +} +/// With View > Snap off nothing snaps. +fn snap_off(options: SnapOptions) { let mut off = options; off.on = false; let (mut fixture, seen) = rig(Snap::new(targets(), off)); diff --git a/crates/ui-patterns/src/patterns/form_dialogs/about.rs b/crates/ui-patterns/src/patterns/form_dialogs/about.rs index 3c4b5c0669..137f6d14c4 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/about.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/about.rs @@ -263,7 +263,6 @@ impl<'a> AboutDialog<'a> { } /// How the About tab lays out the info, and the footer button that goes with it. - #[must_use] pub fn layout(mut self, layout: AboutLayout) -> Self { self.layout = layout; self diff --git a/crates/ui-patterns/src/patterns/form_dialogs/form.rs b/crates/ui-patterns/src/patterns/form_dialogs/form.rs index 74283e42ea..bd786b0c00 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/form.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/form.rs @@ -443,7 +443,7 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { reset_with, on_reset, opening, - held: mut hold, + held: hold, } = self; // A measuring run files and closes nothing: the real run that follows does. let measuring_run = crate::runtime::measure::active(ui.ctx()); @@ -616,10 +616,10 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { let _ = held.reborrow().write(cx, &EditEvent::set(Mixed::Same(before.clone()), values.clone(), name.clone(), None)); *changed.borrow_mut() = Some(values.clone()); } - if let Some((reason, refused)) = &refusal { - if *refused == values { - reason_cell.set(Some(reason.clone())); - } + if let Some((reason, refused)) = &refusal + && *refused == values + { + reason_cell.set(Some(reason.clone())); } if finish && !accept_stays_open { cx.request_close_as(CloseReason::Activated); @@ -634,18 +634,18 @@ impl<'a, V: Value + Default> FormDialog<'a, V> { Some(CloseReason::Enter | CloseReason::Activated) if accepts.get() && hold.is_none() && !no_ok => work.borrow().clone(), _ => None, }; - if let Some(held) = hold.as_deref_mut() { + if let Some(held) = hold { let values = work.into_inner(); - if let (Some((_, refused)), Some(values)) = (held.refusal(), values.as_ref()) { - if refused != values { - held.clear_refusal(); - } + if let (Some((_, refused)), Some(values)) = (held.refusal(), values.as_ref()) + && refused != values + { + held.clear_refusal(); } // The pass reports a press only in the pass that took the input, so a second pass of the frame files nothing. - if let (false, true, Some(0), Some(values)) = (measuring_run, accepts.get(), picked, values.as_ref()) { - if !held.is_waiting() { - held.file(values.clone()); - } + if let (false, true, Some(0), Some(values)) = (measuring_run, accepts.get(), picked, values.as_ref()) + && !held.is_waiting() + { + held.file(values.clone()); } if finish && (accept_stays_open || closed == Some(CloseReason::Activated)) { accepted = held.finish(); diff --git a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs index e7bf11c283..8b801d42ae 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs @@ -22,6 +22,8 @@ use std::cell::{Cell, RefCell}; use std::rc::Rc; use std::sync::Arc; +type UnderList<'a> = Box; + #[cfg(feature = "testing")] mod stories; @@ -311,12 +313,11 @@ pub struct ListManager<'a> { #[prop(into)] cancel_label: Option