Bug 259422

Summary: DocLineComparator behaves ambiguous with empty file
Product: [Eclipse Project] Platform Reporter: Krzysztof Pog這dzi雟ki <intuicje>
Component: CompareAssignee: Platform-Compare-Inbox <platform-compare-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: marcin.marczewski, Szymon.Brandys, tomasz.zarna
Version: 3.5   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Patch_v01
none
Tests_v01
none
mylyn/context/zip
none
Tests_v02
none
Szymon's proposal v01 none

Description Krzysztof Pog這dzi雟ki CLA 2008-12-19 18:13:08 EST
Steps To Reproduce:
1. Envoke "DocLineComparator(doc, null, false)"
2. Envoke "DocLineComparator(doc, new Region(0, doc.getLength()), false)"
(doc has to be an empty document)

Result is different, but basing on Java-doc it should be the same:
"region: if non-null only lines within this range are taken"

Bug has influence on solution of bug 71374
Comment 1 Krzysztof Pog這dzi雟ki CLA 2008-12-19 18:17:59 EST
Created attachment 120985 [details]
Patch_v01

Simple patch solving this problem.
Comment 2 Tomasz Zarna CLA 2008-12-24 06:48:31 EST
Created attachment 121206 [details]
Tests_v01

Krzysztof, are you talking about this kind of situation?
Comment 3 Tomasz Zarna CLA 2008-12-24 06:48:42 EST
Created attachment 121207 [details]
mylyn/context/zip
Comment 4 Krzysztof Pog這dzi雟ki CLA 2008-12-24 08:49:25 EST
Created attachment 121214 [details]
Tests_v02

No, rangesEqual(..) doesn't show the difference. But getRangeCount() does.
Comment 5 Tomasz Zarna CLA 2009-01-26 04:46:04 EST
Both patches are in HEAD + some additional tests. Thanks for the fix Krzysztof!
Comment 6 Szymon Brandys CLA 2009-04-01 10:51:21 EDT
I've been investigating the fix since it caused a regression described in bug 262741.

IMO this is not the right fix. DocLineComparator#getRangeCount should match with IDocument#getNumberOfLines and should return 1 for empty documents. The assumption is that there is always a line, even if a document is empty.
Comment 7 Szymon Brandys CLA 2009-04-01 10:54:16 EDT
Created attachment 130573 [details]
Szymon's proposal v01