Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 130573 Details for
Bug 259422
DocLineComparator behaves ambiguous with empty file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Szymon's proposal v01
259422_20090331.txt (text/plain), 3.12 KB, created by
Szymon Brandys
on 2009-04-01 10:54:16 EDT
(
hide
)
Description:
Szymon's proposal v01
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2009-04-01 10:54:16 EDT
Size:
3.12 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare.tests >Index: src/org/eclipse/compare/tests/DocLineComparatorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java,v >retrieving revision 1.5 >diff -u -r1.5 DocLineComparatorTest.java >--- src/org/eclipse/compare/tests/DocLineComparatorTest.java 26 Jan 2009 09:44:27 -0000 1.5 >+++ src/org/eclipse/compare/tests/DocLineComparatorTest.java 1 Apr 2009 14:54:01 -0000 >@@ -80,7 +80,7 @@ > > Assert.assertTrue(comp1.rangesEqual(0, comp2, 0)); > Assert.assertEquals(comp1.getRangeCount(), comp2.getRangeCount()); >- Assert.assertEquals(0, comp2.getRangeCount()); >+ Assert.assertEquals(1, comp2.getRangeCount()); > } > > public void testOneLine() { >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/DocLineComparator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java,v >retrieving revision 1.20 >diff -u -r1.20 DocLineComparator.java >--- compare/org/eclipse/compare/internal/DocLineComparator.java 26 Jan 2009 09:44:25 -0000 1.20 >+++ compare/org/eclipse/compare/internal/DocLineComparator.java 1 Apr 2009 14:54:03 -0000 >@@ -39,33 +39,36 @@ > * @param region if non-<code>null</code> only lines within this range are taken > * @param ignoreWhiteSpace if <code>true</code> white space is ignored when comparing lines > */ >- public DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) { >- >- fDocument= document; >- fIgnoreWhiteSpace= ignoreWhiteSpace; >- >- fLineOffset= 0; >- if (region == null) { >- region = new Region(0, fDocument.getLength()); >- } >- fLength= region.getLength(); >- int start= region.getOffset(); >- try { >- fLineOffset= fDocument.getLineOfOffset(start); >- } catch (BadLocationException ex) { >- // silently ignored >- } >- >- if (fLength == 0) >- fLineCount= 0; >- else { >- int endLine= fDocument.getNumberOfLines(); >+ public DocLineComparator(IDocument document, IRegion region, >+ boolean ignoreWhiteSpace) { >+ fDocument = document; >+ fIgnoreWhiteSpace = ignoreWhiteSpace; >+ >+ fLineOffset = 0; >+ if (region != null) { >+ fLength = region.getLength(); >+ int start = region.getOffset(); > try { >- endLine= fDocument.getLineOfOffset(start + fLength); >+ fLineOffset = fDocument.getLineOfOffset(start); > } catch (BadLocationException ex) { > // silently ignored > } >- fLineCount= endLine - fLineOffset + 1; >+ >+ if (fLength == 0) { >+ // optimization, empty documents have one line >+ fLineCount = 1; >+ } else { >+ int endLine = fDocument.getNumberOfLines(); >+ try { >+ endLine = fDocument.getLineOfOffset(start + fLength); >+ } catch (BadLocationException ex) { >+ // silently ignored >+ } >+ fLineCount = endLine - fLineOffset + 1; >+ } >+ } else { >+ fLength = document.getLength(); >+ fLineCount = fDocument.getNumberOfLines(); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 259422
:
120985
|
121206
|
121207
|
121214
| 130573