Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 401905

Summary: Compare marks differences in incorrect places
Product: [ECD] Orion Reporter: Malgorzata Janczarska <malgorzata.tomczyk>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 2.0   
Target Milestone: 3.0 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Incorrectly marked diffrences
none
Left side file
none
Right side compare file none

Description Malgorzata Janczarska CLA 2013-02-27 10:01:06 EST
Differences in compare editor are not calculated correctly. The happens when input to compare is two files, not the diff.
Comment 1 Malgorzata Janczarska CLA 2013-02-27 10:04:07 EST
Created attachment 227673 [details]
Incorrectly marked diffrences

At this screenshot you can see that the second difference should be in fact a line higher.
Comment 2 Malgorzata Janczarska CLA 2013-02-27 10:48:18 EST
Created attachment 227675 [details]
Left side file
Comment 3 Malgorzata Janczarska CLA 2013-02-27 10:48:42 EST
Created attachment 227676 [details]
Right side compare file
Comment 4 libing wang CLA 2013-04-24 11:43:20 EDT
was able to reproduce it by comparing the two files in Orion. Will dig out further...
Comment 5 libing wang CLA 2013-05-24 13:46:37 EDT
narrowed down a little bit with something really simple

LEFT:
123
456
789

RIGHT:
321
654
789

It seems if the first line has diff on both side jsdiff treats the line delimeter as a new line common to both side. This fools the compare engine there is a common line on the second line. As a result, all the diff parts are drifting 1 line below.

I also tried a pair like below :
111
123
456
789
   AND, 
111
123
456
789
As the first line is the same, jsdiff does not hit that hole. Everything is fine then.
Comment 6 libing wang CLA 2013-05-24 13:47:31 EDT
> 111
> 123
> 456
> 789
> As the first line is the same, jsdiff does not hit that hole. Everything is
> fine then.
111
321
654
789
Comment 7 libing wang CLA 2013-05-24 15:22:11 EDT
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=a984fc3ad46e41236ac0f8a4f55069bb485250e3.

It turned out that the jsdiff gives back the following stream items, when line ending has "\r\n".

LEFT : first line added, without line end
RIGHT: first line removed, without line end
LEFT&RIGHT: a common line , value is barely a line end
LEFT : second line added, without line end
RIGHT: second line removed, without line end
LEFT&RIGHT: a common line , value is barely a line end
LEFT&RIGHT: a common line , value is "789\r\n"

This stream will mislead the compare engine to generate more diff blocks than expected.

I've improved the jsdiff adapter to handle this hole and added more test cases in compare tests.
Comment 8 libing wang CLA 2013-05-24 15:24:41 EDT
Gosia, good catch.
This will prevent some potential issues in jazzHub if compare page come up because jazzHub's diff does not come from server any more.