zora icon indicating copy to clipboard operation
zora copied to clipboard

Switching between character/line diff?

Open mindplay-dk opened this issue 3 years ago • 1 comments
trafficstars

In the diff reporter, can we have some means of switching between diffChars and diffLines?

diffChars works well for individual strings, but doesn't work so well for multi-line content.

(This is also (presumably) why diffJson internally uses the lineDiff tokenizer.)

The simplest option, I think, would be to have diffStrings check for line-breaks in expected - if line-breaks are present, use diffLines instead of diffChars, which would give an output more similar to that of diffObjects.

Perhaps better, if expected contains line-breaks, to do both a line diff and a character diff, and see which one yields the fewest results - and then render that as the result.

For me, personally, the simplest option would work: just treat multi-line strings as lines.

mindplay-dk avatar Dec 15 '21 14:12 mindplay-dk

That sounds like a good idea

lorenzofox3 avatar Dec 16 '21 13:12 lorenzofox3