diff --git a/crates/edit/src/images.rs b/crates/edit/src/images.rs index f4680bcc5c..45d07da662 100644 --- a/crates/edit/src/images.rs +++ b/crates/edit/src/images.rs @@ -239,11 +239,9 @@ impl ImageState { self.path.curve_to(p1, end, end); } } - b"h" => { - // ClosePath with no subpath panics by the same contract (#3581). - if self.has_current_point() { - self.path.close_path(); - } + // ClosePath with no subpath panics by the same contract (#3581). + b"h" if self.has_current_point() => { + self.path.close_path(); } b"re" => { if let Some([x, y, w, h]) = op.nums::<4>() diff --git a/crates/ui-egui/src/app/files.rs b/crates/ui-egui/src/app/files.rs index 9991047077..838e809e74 100644 --- a/crates/ui-egui/src/app/files.rs +++ b/crates/ui-egui/src/app/files.rs @@ -60,11 +60,8 @@ impl PdfCraftApp { let info = self.session.get(view.id).map(|d| &d.info); match info.and_then(|i| i.open_dest.filter(|(page, _)| *page < pages).map(|d| (i, d))) { Some((info, (page, dest))) if !self.always_default_view => view.go_to_dest(page, dest, info), - Some((_, (page, _))) => { - if page > 0 { - view.go_to_page(page); - } - } + Some((_, (page, _))) if page > 0 => view.go_to_page(page), + Some(_) => {} None if v.page > 0 && v.page < pages => view.go_to_page(v.page), None => {} } diff --git a/crates/ui-egui/src/panels/comments_panel.rs b/crates/ui-egui/src/panels/comments_panel.rs index d54daf5717..c71baffd77 100644 --- a/crates/ui-egui/src/panels/comments_panel.rs +++ b/crates/ui-egui/src/panels/comments_panel.rs @@ -407,7 +407,7 @@ fn card(ui: &mut egui::Ui, view: &mut DocView, context: CardContext<'_>) -> Opti let head = ui.horizontal(|ui| { above = avatar(ui, t, Some(subtype_icon(&a.subtype)), None, color); // The catalogue and author names stay logical: egui lays out RTL text itself. - let author = a.author.as_deref().map_or_else(|| tl!("Unknown author"), |name| name); + let author = a.author.as_deref().unwrap_or_else(|| tl!("Unknown author")); ui.label(egui::RichText::new(author).font(theme::semibold(12.5)).color(t.text)); if let Some(m) = &a.modified { ui.add(egui::Label::new(egui::RichText::new(m).font(theme::regular(11.0)).color(t.text_faint)).truncate()); @@ -471,7 +471,7 @@ fn card(ui: &mut egui::Ui, view: &mut DocView, context: CardContext<'_>) -> Opti ui.vertical(|ui| { ui.spacing_mut().item_spacing.y = 2.0; ui.horizontal(|ui| { - let author = r.author.as_deref().map_or_else(|| tl!("Reply"), |name| name); + let author = r.author.as_deref().unwrap_or_else(|| tl!("Reply")); ui.label(egui::RichText::new(author).font(theme::semibold(12.0))); if let Some(m) = &r.modified { ui.add(egui::Label::new(egui::RichText::new(m).font(theme::regular(11.0)).color(t.text_faint)).truncate()); diff --git a/crates/ui-egui/src/workflows/combine_ui/actions.rs b/crates/ui-egui/src/workflows/combine_ui/actions.rs index a4f80abdc8..420f12a08e 100644 --- a/crates/ui-egui/src/workflows/combine_ui/actions.rs +++ b/crates/ui-egui/src/workflows/combine_ui/actions.rs @@ -267,15 +267,11 @@ impl PdfCraftApp { let ids: Vec = self.combine_draft.iter().map(|f| f.id).collect(); let tab = &mut self.combine_tab; match action { - RowAction::Preview(id) => { - if ids.contains(&id) { - self.combine_tab.preview = Some(Preview { file: id, at: 0, page: None, pages: None }); - } + RowAction::Preview(id) if ids.contains(&id) => { + self.combine_tab.preview = Some(Preview { file: id, at: 0, page: None, pages: None }); } - RowAction::PreviewAt(id, at) => { - if ids.contains(&id) { - self.combine_tab.preview = Some(Preview { file: id, at, page: None, pages: None }); - } + RowAction::PreviewAt(id, at) if ids.contains(&id) => { + self.combine_tab.preview = Some(Preview { file: id, at, page: None, pages: None }); } RowAction::Expand(id, on) => { if on { diff --git a/crates/ui-egui/src/workflows/compare_ui.rs b/crates/ui-egui/src/workflows/compare_ui.rs index 939d5fed3e..524d374485 100644 --- a/crates/ui-egui/src/workflows/compare_ui.rs +++ b/crates/ui-egui/src/workflows/compare_ui.rs @@ -318,7 +318,7 @@ fn shading(s: &CompareState, old: bool) -> Vec<(usize, [f32; 4], Color32)> { for (p, r) in &s.visual { let r = r.map(|v| v as f32); // The old file's half also skips a region overlapping one it already shades. - if !overlaps(*p, r, &text) && !(old && overlaps(*p, r, &visual)) { + if !(overlaps(*p, r, &text) || old && overlaps(*p, r, &visual)) { visual.push((*p, r, VISUAL)); } } diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index c4231d0f69..ce748293e6 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -4797,7 +4797,7 @@ fn image_edge_handle_stretch_and_crop_mode() { // Confirm crop with Enter key h.key_press(egui::Key::Enter); h.run_steps(4); - assert!(!h.state().views[0].image_selection.as_ref().is_some_and(|s| s.crop.is_some())); + assert!(h.state().views[0].image_selection.as_ref().is_none_or(|s| s.crop.is_none())); let doc_id = h.state().views[0].id; let images = h.state().session.get(doc_id).unwrap().page_images(0); assert_eq!(images.len(), 1, "image still exists: {images:?}"); @@ -7490,7 +7490,7 @@ fn added_and_pasted_image_uses_refactored_image_edits() { set_crop_box(&mut h, smaller); h.key_press(egui::Key::Enter); h.run_steps(4); - assert!(!h.state().views[0].image_selection.as_ref().is_some_and(|s| s.crop.is_some()), "crop mode exited"); + assert!(h.state().views[0].image_selection.as_ref().is_none_or(|s| s.crop.is_none()), "crop mode exited"); let images_after_crop = h.state().session.get(id).unwrap().page_images(0); assert!(images_after_crop[0].visible_rect.is_some());