zgrossbart / jdd

A semantic JSON compare tool
http://www.jsondiff.com
Apache License 2.0
1.03k stars 180 forks source link

Collapse (hide) same lines #70

Open fzyzcjy opened 4 months ago

fzyzcjy commented 4 months ago

Hi thanks for the diff tool! It would be great if, when there are a ton of exactly same lines, they can be folded, such that the diff is much shorter. For example, SmartGit has something like:

image

zgrossbart commented 4 months ago

Thank you for using JSONDiff @fzyzcjy and a big thank you for the feature suggestion.

I've looked into code folding before. The sample in your screenshot is hiding lines that don't have any differences. Would you want JSONDiff to do the same thing and collapse sections that don't have any differences or do you have another idea for how you'd want to see this working?

fzyzcjy commented 4 months ago

Thanks for the reply!

Would you want JSONDiff to do the same thing and collapse sections that don't have any differences or do you have another idea for how you'd want to see this working?

I guess the simplest solution is to just collapse anything that does not change. For optional better experience, I would like to see the parent keys be shown. For example, suppose we want to compare:

{a: b: {c: 1, d: 1, e: 1, ... x: 1, y: 2, z: 1}}}
{a: b: {c: 1, d: 1, e: 1, ... x: 1, y: 10000, z: 1}}}

Then, the naive way will only show the y line (together with a few lines above and below it). But then we do not know what is indeed the parent key of y (here it is a.b.y). Thus, it would be great to somehow show such information for readers.

zgrossbart commented 4 months ago

Thank you for the extra details @fzyzcjy. Let me take a little time to think about the best user experience here and see what I can come up with.

fzyzcjy commented 4 months ago

Sure, take your time and looking forward!