fix: key inserted array indices by name in the array-methods plugin
Before adoption: this commit came in with the history the project adopted, so no landing records it.
`handleInsertedValues` recorded inserted indices in `assigned_` as numbers, but `assigned_` is keyed by property name everywhere else, because the proxy traps only ever see strings. Patch generation looks indices up with `assigned_?.get(i.toString())`, so a numeric key was never found. The added indices loop in `generateArrayPatches` covers everything past `base_.length` regardless of `assigned_`, which hid the mismatch for a plain push. It surfaced when an insert reuses an index that already existed in the base, e.g. dropping the oldest entry and appending a new one: const [next, patches] = produceWithPatches(["a", "b", "c"], draft => { draft.pop() draft.push("z") }) // next -> ["a", "b", "z"] // patches -> [] (expected: replace /2 with "z") The result was correct but no patch described it, so undo/redo and state sync built on the patch stream silently dropped the change. Stringifying the index also keeps the key consistent for the finalization lookup in `handleCrossReference`, which reads `assigned_` with the same key this function passes it.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+23 added−1 removed
- tests:+17 added−0 removed
- other:+6 added−1 removed