inkandswitch / vscode-hypermerge

A VSCode plugin to edit Hypermerge documents
28 stars 3 forks source link

DeepDiff can't add >1 element to a list in a single go #24

Closed pvh closed 5 years ago

pvh commented 5 years ago

Automerge won't let you set element 7 of a 5 element array (though maybe it should, @ept? it's legal with Javascript arrays). DeepDiff returns addition of new elements in an arbitrary order and so it may try to add element 7 before element 6, which crashes during save.

jeffpeterson commented 5 years ago

fixed with odiff

ept commented 5 years ago

@pvh The reason I didn't allow Automerge to set element 7 of a 5-element array is that the 6th element would have to be filled in with undefined, and Automerge does not support undefined values (partly because JSON doesn't have undefined either, and partly because most other languages don't distinguish between null and undefined, so making the distinction would make Automerge harder to port to other languages). The alternative would be to fill in the 6th element with null, but that feels even more wrong. I'd rather just have it throw an exception when you try to assign outside of the bounds of the array.