← Commit history

Return unchanged zone plans without rerunning DRC

John Lauer ·c417660bc7 ·1mo ago ·parent 6e873f2
1 file changed +12−1
rust/crates/kicad-core/src/ipc.rs+12−1
@@ -931,6 +931,17 @@ pub fn apply_zone_plan(ctx: &Ctx, args: &Value) -> RResult<Value> {     let (text, board, revision) = s.snapshot()?;     check_revision(args, &revision)?;     let plan = crate::zone_plan::prepare(&text, &board, args)?;+    if plan.remove.is_empty() && plan.create.is_empty() {+        // No candidate differs from the current board. A capped inherited DRC+        // report must not turn an idempotent read into a failed mutation.+        return Ok(json!({+            "success":true,"mutated":false,"undoSteps":0,"revision":revision,+            "dryRun":args["dryRun"]==true,"unchangedIds":plan.unchanged,+            "ownedItemIds":plan.unchanged,"itemIds":[],"removedIds":[],+            "drcRerun":false,"_hint":"Native zone definitions already match; no edit or DRC rerun. This is not a DRC-clean certification."+        }));+    }+     let before = drc_snapshot(ctx.kicad_cli.as_deref(), &s.source_path(), &text)?;     let check = drc_snapshot(ctx.kicad_cli.as_deref(), &s.source_path(), &plan.candidate)?;     let added = new_errors(&before, &check)?;@@ -942,7 +953,7 @@ pub fn apply_zone_plan(ctx: &Ctx, args: &Value) -> RResult<Value> {         .with("violations", json!(added))         .with("mutated", json!(false)));     }-    if args["dryRun"] == true || (plan.remove.is_empty() && plan.create.is_empty()) {+    if args["dryRun"] == true {         return Ok(             json!({"success":true,"mutated":false,"dryRun":args["dryRun"]==true,"revision":revision,"unchangedIds":plan.unchanged,"wouldRemoveIds":plan.remove,"wouldCreate":plan.create.iter().map(zones::ZoneSpec::public).collect::<Vec<_>>(),"drc":check,"undoSteps":0}),         );