diff --git a/crates/doc/src/math_linear.rs b/crates/doc/src/math_linear.rs index 3f077f377..39a25ab5d 100644 --- a/crates/doc/src/math_linear.rs +++ b/crates/doc/src/math_linear.rs @@ -570,7 +570,7 @@ impl P { } out.pop() }; - if !matches!(c, '^' | '_') && !(matches!(c, '┬' | '┴') && self.no_limits == 0) && !is_combining(c) { + if !(matches!(c, '^' | '_') || matches!(c, '┬' | '┴') && self.no_limits == 0 || is_combining(c)) { break; } // The base is already deep: the operator is text (see `too_deep`). diff --git a/crates/docbin/src/officeart.rs b/crates/docbin/src/officeart.rs index 6d35d929d..fd665874d 100644 --- a/crates/docbin/src/officeart.rs +++ b/crates/docbin/src/officeart.rs @@ -377,21 +377,15 @@ impl Props { } 0x0104 => self.pib = Some(op), 0x0181 => self.fill_color = color(op), - 0x01BF => { - // fFilled (bit 4) is valid when fUsefFilled (bit 20) is set. - if op & (1 << 20) != 0 { - self.filled = Some(op & (1 << 4) != 0); - } - } + // fFilled (bit 4) is valid when fUsefFilled (bit 20) is set. + 0x01BF if op & (1 << 20) != 0 => self.filled = Some(op & (1 << 4) != 0), + 0x01BF => {} 0x01C0 => self.line_color = color(op), 0x01CB => self.line_width = Some(op), 0x01D0 | 0x01D1 => self.arrowhead |= op != 0, - 0x01FF => { - // fLine (bit 3) is valid when fUsefLine (bit 19) is set. - if op & (1 << 19) != 0 { - self.line = Some(op & (1 << 3) != 0); - } - } + // fLine (bit 3) is valid when fUsefLine (bit 19) is set. + 0x01FF if op & (1 << 19) != 0 => self.line = Some(op & (1 << 3) != 0), + 0x01FF => {} 0x0384..=0x0387 => self.wrap_dist[(pid - 0x0384) as usize] = Some(op), 0x038F => self.posh = Some(op), 0x0390 => self.posrelh = Some(op), diff --git a/crates/docx/src/read/story.rs b/crates/docx/src/read/story.rs index 40b9b7418..73c93cae7 100644 --- a/crates/docx/src/read/story.rs +++ b/crates/docx/src/read/story.rs @@ -732,11 +732,10 @@ impl Reader<'_> { }; self.emit_text(sc, pb, c, props); } - "w:cr" => { - if !sc.fields.iter().any(|f| f.phase == Phase::Instr) { - self.emit_text(sc, pb, "\n", props); - } + "w:cr" if !sc.fields.iter().any(|f| f.phase == Phase::Instr) => { + self.emit_text(sc, pb, "\n", props); } + "w:cr" => {} "w:noBreakHyphen" => self.emit_text(sc, pb, "\u{2011}", props), "w:softHyphen" => self.emit_text(sc, pb, "\u{00AD}", props), "w:sym" => { diff --git a/crates/engine/src/cmd/connectors.rs b/crates/engine/src/cmd/connectors.rs index f35adec04..1746c26ca 100644 --- a/crates/engine/src/cmd/connectors.rs +++ b/crates/engine/src/cmd/connectors.rs @@ -321,28 +321,11 @@ mod tests { rot: f32, flip_h: bool, flip_v: bool, - group: InlineObject, } impl ScaledGroupSpec { fn new(w: f32, h: f32, kind: ShapeKind, rot: f32, flip_h: bool, flip_v: bool) -> Self { - let group = InlineObject::Group { - w, - h, - ch_w: 200.0, - ch_h: 300.0, - float: Float { rot: 25.0, flip_h: true, ..Default::default() }, - canvas: None, - children: vec![ - GroupChild { x: 100.0, y: 200.0, obj: shape(ShapeKind::Rectangle, ShapeExtra { id: 7, ..Default::default() }, Float::default()) }, - GroupChild { - x: 10.0, - y: 30.0, - obj: shape(kind, ShapeExtra { start: None, end: None, ..Default::default() }, Float { rot, flip_h, flip_v, ..Default::default() }), - }, - ], - }; - Self { w, h, kind, rot, flip_h, flip_v, group } + Self { w, h, kind, rot, flip_h, flip_v } } } @@ -376,7 +359,11 @@ mod tests { GroupChild { x: 10.0, y: 30.0, - obj: shape(spec.kind, ShapeExtra { start, end, ..Default::default() }, Float { rot: spec.rot, flip_h: spec.flip_h, flip_v: spec.flip_v, ..Default::default() }), + obj: shape( + spec.kind, + ShapeExtra { start, end, ..Default::default() }, + Float { rot: spec.rot, flip_h: spec.flip_h, flip_v: spec.flip_v, ..Default::default() }, + ), }, ], }; @@ -393,7 +380,15 @@ mod tests { assert!( (actual.0 - expected.0).abs() < 0.001 && (actual.1 - expected.1).abs() < 0.001, "{}x{}, {:?}, {}, {}, {}, {}: {:?} != {:?}", - spec.w, spec.h, spec.kind, spec.rot, spec.flip_h, spec.flip_v, free_start, actual, expected + spec.w, + spec.h, + spec.kind, + spec.rot, + spec.flip_h, + spec.flip_v, + free_start, + actual, + expected ); let InlineObject::Group { children, .. } = group else { panic!("group") }; let c = &children[1]; diff --git a/crates/engine/src/cmd/text.rs b/crates/engine/src/cmd/text.rs index 9a1762866..f0e10e843 100644 --- a/crates/engine/src/cmd/text.rs +++ b/crates/engine/src/cmd/text.rs @@ -899,7 +899,7 @@ fn tab_indent_on(s: &Session) -> bool { fn tab_indents(s: &mut Session, f: &Pos) -> bool { let Some(para) = s.doc.para_at(f).filter(|p| !p.is_empty()) else { return false }; if f.off == 0 { - return !s.doc.styles.resolve_para(¶.props).numbering.is_some_and(|n| n.num != 0); + return s.doc.styles.resolve_para(¶.props).numbering.is_none_or(|n| n.num == 0); } let l = s.layout(); l.line_bounds(f, s.page_hint).is_some_and(|(a, _)| a == *f) diff --git a/crates/fonts/src/tests_sysfonts.rs b/crates/fonts/src/tests_sysfonts.rs index c5b63caf4..132535456 100644 --- a/crates/fonts/src/tests_sysfonts.rs +++ b/crates/fonts/src/tests_sysfonts.rs @@ -1,6 +1,5 @@ //! Installed system fonts: found by family name by every lookup, whatever ran before it (#22). #[allow(unused_imports)] - use std::path::{Path, PathBuf}; use super::*; diff --git a/crates/layout/src/lib.rs b/crates/layout/src/lib.rs index 6771be76b..dc27ea8ea 100644 --- a/crates/layout/src/lib.rs +++ b/crates/layout/src/lib.rs @@ -4528,7 +4528,7 @@ fn place_table(ctx: &mut Ctx, pb: &mut PageBuilder, t: &wordcraft_doc::Table, bl && !pb.at_top() && !fresh && rest.is_none() - && !ri.checked_sub(1).and_then(|prev| kept.get(prev)).is_some_and(|&(end, _)| end >= ri) + && ri.checked_sub(1).and_then(|prev| kept.get(prev)).is_none_or(|&(end, _)| end < ri) && kept.get(ri).is_some_and(|&(end, height)| { if end == ri { return false; diff --git a/crates/proof/src/affix.rs b/crates/proof/src/affix.rs index 03fc27a6b..4ec068466 100644 --- a/crates/proof/src/affix.rs +++ b/crates/proof/src/affix.rs @@ -314,13 +314,12 @@ fn parse_aff(aff: &str) -> Result { match dir { "SET" | "LANG" | "NAME" | "VERSION" | "HOME" | "WORDCHARS" | "MAXNGRAMSUGS" | "MAXDIFF" | "ONLYMAXDIFF" | "NOSPLITSUGS" | "SUGSWITHDOTS" | "WARN" | "FORBIDWARN" | "MAXCPDSUGS" => {} - "FLAG" => { - // Per-character flag modes (`FLAG UTF-8`, as VERO's pt_BR dictionary uses) work - // with the one-character parsing here; only the multi-character encodings differ. - if !matches!(at(1), "UTF-8" | "DEFAULT" | "utf-8" | "default" | "UTF8" | "") { - return Err(format!("line {}: FLAG {} is not supported (one-character flags only)", n + 1, at(1))); - } + // Per-character flag modes (`FLAG UTF-8`, as VERO's pt_BR dictionary uses) work + // with the one-character parsing here; only the multi-character encodings differ. + "FLAG" if !matches!(at(1), "UTF-8" | "DEFAULT" | "utf-8" | "default" | "UTF8" | "") => { + return Err(format!("line {}: FLAG {} is not supported (one-character flags only)", n + 1, at(1))); } + "FLAG" => {} directive @ ("FORBIDDENWORD" | "NOSUGGEST") => { let mut it = at(1).chars().filter(|&c| c != EMOJI_SELECTOR); match (it.next(), it.next()) { diff --git a/crates/ui-egui/src/dialogs_layout.rs b/crates/ui-egui/src/dialogs_layout.rs index e0e0f5222..f983ed8cb 100644 --- a/crates/ui-egui/src/dialogs_layout.rs +++ b/crates/ui-egui/src/dialogs_layout.rs @@ -952,7 +952,7 @@ fn alert(ui: &mut Ui, text: &Option) { fn split_cells_ui(app: &mut WordApp, ui: &mut Ui, f: &mut SplitCellsForm) -> bool { // Several cells split one by one keep their rows. - let rows_on = !(f.cells > 1 && !f.merge_first); + let rows_on = f.cells <= 1 || f.merge_first; egui::Grid::new("split_cells").num_columns(2).show(ui, |ui| { ui.label(tl!("Number of columns:")); ui.add(egui::DragValue::new(&mut f.columns).range(1..=63)); diff --git a/crates/ui-egui/src/keytips.rs b/crates/ui-egui/src/keytips.rs index a874e2156..7ecc99039 100644 --- a/crates/ui-egui/src/keytips.rs +++ b/crates/ui-egui/src/keytips.rs @@ -773,7 +773,7 @@ pub fn logic(app: &mut WordApp, ctx: &egui::Context) { } // Alt off while an Alt key is still down (AltGr on Linux turns Level 3 Shift on, not // Alt): the key's release ends the press, not this. - egui::Event::ModifiersChanged(modifiers) if !(app.ui.alt_key_down && !modifiers.alt) => { + egui::Event::ModifiersChanged(modifiers) if !app.ui.alt_key_down || modifiers.alt => { alt_released |= alt_transition(app, modifiers.alt, *modifiers); } egui::Event::PointerButton { pressed: true, .. } => { diff --git a/crates/ui-egui/src/objects.rs b/crates/ui-egui/src/objects.rs index c60737859..afc83fcd2 100644 --- a/crates/ui-egui/src/objects.rs +++ b/crates/ui-egui/src/objects.rs @@ -272,7 +272,7 @@ pub fn pointer(app: &mut WordApp, ui: &Ui, resp: &egui::Response, pages: &[Rect] let adding = ui.input(|i| i.modifiers.shift || i.modifiers.command); // Ctrl on the object that is already selected starts a copy-drag instead. let again = selected(app).is_some_and(|(p, _)| p == object.pos()); - if pressed && adding && grab == Grab::Move && selected(app).is_some() && !(again && !ui.input(|i| i.modifiers.shift)) { + if pressed && adding && grab == Grab::Move && selected(app).is_some() && (ui.input(|i| i.modifiers.shift) || !again) { let _ = app.run("select.addObject", json!({"pos": object.pos()})); return true; } diff --git a/xtask/src/visual_diff.rs b/xtask/src/visual_diff.rs index 20f857c98..b0259af88 100644 --- a/xtask/src/visual_diff.rs +++ b/xtask/src/visual_diff.rs @@ -37,7 +37,7 @@ pub fn run(args: &[&str]) -> Result<(), String> { None => 100, }; let pos: Vec<&str> = - args.iter().enumerate().filter(|(i, a)| !a.starts_with("--") && !(*i > 0 && args[i - 1] == "--dpi")).map(|(_, a)| *a).collect(); + args.iter().enumerate().filter(|(i, a)| !(a.starts_with("--") || *i > 0 && args[i - 1] == "--dpi")).map(|(_, a)| *a).collect(); let [reference, test, out] = pos.as_slice() else { return Err("usage: cargo xtask visual-diff REF.pdf TEST.pdf OUTDIR [--private] [--dpi N]".into()); };