Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369744 - [Search]Compare view diff annotation is one line off on some rare files.
Summary: [Search]Compare view diff annotation is one line off on some rare files.
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.4 RC1   Edit
Assignee: libing wang CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-25 16:18 EST by libing wang CLA
Modified: 2012-02-09 18:37 EST (History)
0 users

See Also:


Attachments
Screen shot (54.80 KB, image/png)
2012-01-25 16:22 EST, libing wang CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description libing wang CLA 2012-01-25 16:18:39 EST
I happened to find this rare case while testing today.

1.Search on key word "new". 
2.In the result page, go to ptions->"sort by name" then click on replace and enter "becomeOld".
3.In the preview page, click on annotations.js and expand it.
4.Click on the second match.

In the compare view you will see the changed match is properly highlighted as a pair but the diff block is annotated one line below that.

Not sure if jsDiff is wrong or I am wrong but need investigation for M2.
Comment 1 libing wang CLA 2012-01-25 16:22:25 EST
Created attachment 210084 [details]
Screen shot
Comment 2 libing wang CLA 2012-02-09 18:37:20 EST
fixed with 
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=8ea6c50c1ab37d056be007e4c356417938ee2e84.

Basically the jsDiffAdapter.js assumed that all diff blocks returned by jsdiff.diffLines are the following pattern:

unchanged block (foo\n)
added block or nothing(bar\n)
removed block or nothing(coo\n)
unchanged block (fooo\n)
added block or nothing(baar\n)
removed block or nothing(cooo\n)

But sometimes it returns something like this

unchanged block (foo\n)
added block or nothing(bar)
removed block or nothing(coo)
unchanged block (\nfooo\n)
added block or nothing(baar)
removed block or nothing(cooo)

We should be careful on counting the unchanged block length because at very beginning it may contain a line delimeter that is supposed to be contained in the previous  added/removed block.