From 60bc9172f1e848a02d4fbad6266f79f7183dc67f Mon Sep 17 00:00:00 2001 From: furao Date: Sat, 13 Jun 2026 14:06:00 +0800 Subject: [PATCH] =?UTF-8?q?[cli]=20=E4=BF=AE=E5=A4=8D:=20dry-run=20diff=20?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E9=95=BF=E5=BA=A6=E5=8F=98=E5=8C=96=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E4=B8=BA=20index=20=E5=A4=84=E7=BD=AE=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli/src/editor/diff.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cli/src/editor/diff.js b/cli/src/editor/diff.js index 4d6f177..9c3c8f2 100644 --- a/cli/src/editor/diff.js +++ b/cli/src/editor/diff.js @@ -39,6 +39,13 @@ function diffObject(a, b, prefix, out) { out[prefix || ''] = [a, b]; return; } + // 数组长度不同:整数组替换。按 index 递归会把"数组截断/扩展"误报成 + // "该位置变 undefined",JSON 序列化时 undefined → null,看上去像被置空了 + // 一个 null 槽位(例:[x] → [] 误报成 ".0: [x, null]")。 + if (Array.isArray(a) && Array.isArray(b) && a.length !== b.length) { + out[prefix || ''] = [a, b]; + return; + } const keys = new Set([...Object.keys(a), ...Object.keys(b)]); for (const k of keys) { const av = a[k];