Bug 259422 - DocLineComparator behaves ambiguous with empty file
Summary: DocLineComparator behaves ambiguous with empty file
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 minor (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-19 18:13 EST by Krzysztof Pog這dzi雟ki CLA
Modified: 2009-04-01 10:54 EDT (History)
3 users (show)

See Also:


Attachments
Patch_v01 (1.78 KB, patch)
2008-12-19 18:17 EST, Krzysztof Pog這dzi雟ki CLA
no flags Details | Diff
Tests_v01 (1.64 KB, patch)
2008-12-24 06:48 EST, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (4.36 KB, application/octet-stream)
2008-12-24 06:48 EST, Tomasz Zarna CLA
no flags Details
Tests_v02 (1.65 KB, text/plain)
2008-12-24 08:49 EST, Krzysztof Pog這dzi雟ki CLA
no flags Details
Szymon's proposal v01 (3.12 KB, patch)
2009-04-01 10:54 EDT, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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