From 4586629f8337ce865440f2546ea46dbbb6fcb44e Mon Sep 17 00:00:00 2001 From: yoriswind Date: Sat, 28 Nov 2026 10:43:57 -0800 Subject: [PATCH] Keep explicit stroke wire defaults while fixing lint --- crates/paint/src/brush_pose_no_pen_tests.rs | 4 +++- crates/paint/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/paint/src/brush_pose_no_pen_tests.rs b/crates/paint/src/brush_pose_no_pen_tests.rs index 001789db7d..1e9b4a98d5 100644 --- a/crates/paint/src/brush_pose_no_pen_tests.rs +++ b/crates/paint/src/brush_pose_no_pen_tests.rs @@ -30,13 +30,15 @@ fn missing_pressure_survives_serialization_without_reclassifying_explicit_one() let absent: StrokePoint = serde_json::from_value(json!({"x": 20, "y": 30})).unwrap(); let supplied: StrokePoint = serde_json::from_value(json!({"x": 20, "y": 30, "pressure": 1})).unwrap(); assert_eq!(absent.pressure, supplied.pressure); + assert_eq!(absent.wheel, 1.0, "missing wire wheel keeps the legacy full input"); + assert_eq!(supplied.wheel, 1.0, "explicit pen pressure does not change the wheel default"); assert!(!absent.pressure_present); assert!(supplied.pressure_present); let absent_half = StrokePoint { pressure: 0.5, ..absent }; for point in [absent, supplied, absent_half] { let wire = serde_json::to_value(point).unwrap(); assert_eq!(wire.get("pressure").is_some(), point.pressure_present || point.pressure != 1.0); - assert_eq!(wire.get("pressurePresent").cloned(), (!point.pressure_present).then(|| json!(false))); + assert_eq!(wire.get("pressurePresent").cloned(), (!point.pressure_present).then_some(json!(false))); assert_eq!(serde_json::from_value::(wire).unwrap(), point); } let points = [absent_half, StrokePoint { x: 155.0, ..absent_half }]; diff --git a/crates/paint/src/lib.rs b/crates/paint/src/lib.rs index 3e6f599cf7..ad0b8195e2 100644 --- a/crates/paint/src/lib.rs +++ b/crates/paint/src/lib.rs @@ -110,8 +110,8 @@ fn present_pressure<'de, D: serde::Deserializer<'de>>(d: D) -> Result Self { - // Missing wire fields must infer provenance from pressure, not inherit a false override. - Self { pressure: None, pressure_present: None, ..StrokePoint::without_pressure(0.0, 0.0).into() } + // Neutral provenance infers from pressure; missing stylus wheel retains its legacy 1. + Self { x: 0.0, y: 0.0, pressure: None, pressure_present: None, tilt_x: 0.0, tilt_y: 0.0, rotation: 0.0, wheel: 1.0, time: 0.0 } } }