Collapse repeated elision into one line
FireyFly opened this issue · comments
Currently, when diffing arrays, elements that are objects and equivalent on both sides get elided with a ...
. However, the fact that the elision marker is there is important to highlight the position of the differences in the array.
In some cases (especially when diffing API responses and similar), the arrays might be very long, and the output gets rather tedious. Instead of one elision marker for each elided object, I suggest to replace repetated elision with a single line.
E.g.,
% json-diff <(echo '{ "hello": [{},{},{},{},{},{},1] }') <(echo '{ "hello": [{},{},{},{},{},{},2] }')
{
hello: [
...
...
...
...
...
...
- 1
+ 2
]
}
would instead become
% json-diff <(echo '{ "hello": [{},{},{},{},{},{},1] }') <(echo '{ "hello": [{},{},{},{},{},{},2] }')
{
hello: [
... (6 entries)
- 1
+ 2
]
}
For smaller arrays, it would get noisy and reduce clarity to use the elisions everywhere. Therefore, I think it makes sense to by default only collapse e.g. 5 or more elisions into one line. Probably makes sense to provide a command-line flag to set this threshold, though!