Page 1 of 1

Ignore blank lines

Posted: Fri Jul 05, 2019 11:55 am
by MSpagni
I have a problem regarding the blank (empty) lines.

Suppose you have 2 files like this.
file 1:

Code: Select all

aaaaaa  
(blank) 
cccccc  
file 2

Code: Select all

aaaaaa  
(blank) 
bbbbbb  
cccccc  
Comparing the two files with "ignore blank lines" produces results like this:

Code: Select all

file 1           file 2

aaaaaa           aaaaaa
(dummy)          (blank)
(dummy)          bbbbbb
(blank)          (dummy)
cccccc           cccccc
This is a minor annoyance if you just look at it but, if you copy a block from a side to the other, regularily you finish by having the blank line in the wrong position all the times and you must adjust it manually. Quite annoying.

Just in case, what I'd like to see would be:

Code: Select all

file 1           file 2

aaaaaa           aaaaaa
(blank)          (blank)
(dummy)          bbbbbb
cccccc           cccccc
I understand that I requested that the blank lines are ignored for the matter of comparison, but if they are shown (and copied) then a bit of consideration for them is due. :wink:
I have no idea on how to progrmmatically take care of this. I hope in you.

Re: Ignore blank lines

Posted: Fri Jul 05, 2019 1:54 pm
by psguru
Hmm, I get a different result:

Blank Lines.png
Blank Lines.png (9.19 KiB) Viewed 12846 times

Re: Ignore blank lines

Posted: Fri Jul 05, 2019 11:56 pm
by MSpagni
Possibly there is more than meets the eye.
Please, try with the attached files.

Re: Ignore blank lines

Posted: Sat Jul 06, 2019 10:30 am
by psguru
Yes, I see what you mean, and I'm sure I answered this question before. Here's what I get:

Blank Lines 1.png
Blank Lines 1.png (17.95 KiB) Viewed 12834 times
So yes, since blank lines are ignored, the diff algorithm doesn't care about them, and they are added to respective spots after comparison. The way it does it is like this: the blank line in the left file, line 13, is before line 14. On the right, the blank line 13 is before line 14. So they are placed in their respective places after comparison. While in this case it seems counter-intuitive, it's hard to generalize this algorithm (and we tried),

While it's a little annoying, you can either switch off ignores (or not ignore blank lines):

Blank Lines 2.png
Blank Lines 2.png (18.26 KiB) Viewed 12834 times
or use, for this rare occasion, manual line synchronization feature:

Blank Lines 3.png
Blank Lines 3.png (18.53 KiB) Viewed 12834 times

Re: Ignore blank lines

Posted: Sat Jul 06, 2019 11:48 pm
by MSpagni
I'm sure I answered this question before.
Now that you say it, I think you're right.
Sorry for having revived the topic, but in this period it has become especially annoying for me.

There must be some kind of algorithm.
Maybe a quick post-processing of the comparison results.
After all, the problem is only when comparing with "Ignore blank lines" and you have blank lines before and/or after a block of differences.
Only in this case, find how to maximize the matching of the common blank lines and let the other blank lines have their place like now.
Do you think it's feasible?

Re: Ignore blank lines

Posted: Sun Jul 07, 2019 12:09 pm
by psguru
Perhaps although I'm pretty sure we already looked into implementing this and, for whatever reason, did not. We'll have another look.

Re: Ignore blank lines

Posted: Mon Jul 08, 2019 10:24 am
by MSpagni
Nothing is impossible for the man who doesn't have to do the work! :lol:

Re: Ignore blank lines

Posted: Tue Jul 09, 2019 9:25 am
by MSpagni
Ehm...
Same problem with the comments when ignored... :roll:

Re: Ignore blank lines

Posted: Tue Jul 09, 2019 9:31 am
by psguru
Yes, it's the same logic for all ignored lines.

Re: Ignore blank lines

Posted: Sat Jul 13, 2019 2:57 pm
by psguru
Good news! Your persistence paid off: it's a bug. It manifests itself in scenarios your posted but only for the second diff or any diff after that. The fix will appear in the next build.

Re: Ignore blank lines

Posted: Mon Jul 15, 2019 5:22 am
by MSpagni
Wow! I'm very glad. :!:
I also feared you started to hate me... :wink:

Out of joke: now that you explained it, I understand why my first attempt to get an example failed but I still had problems.
Had I investigated a bit deeply I could have saved you a lot of work. Sorry.

Thank you very much, as always.

Re: Ignore blank lines

Posted: Mon Jul 15, 2019 9:54 am
by psguru
No, no hate ;). And thanks for pursuing it.