Project: JDT
Bug 43352 IBuffer not line delimiter aware
Reported: 2003-09-19 09:53:48 | Status: resolved fixed

20030919 The buffer adapter provided from org.eclipse.core.filebuffers nomalizes all text coming from IBuffer.append, IBuffer.replace and IBuffer.setContents to ensure line delimiter consistency. When working copies are created IBuffer.setContents is used what leads to the normalization of the whole source content. This is not wanted, only new text should be normalized. See test case PrimaryWorkingCopyTest.testLineDelimiterConsistency2 Suggestion is to - either add a new method setRawContent that does not normalize or - make IBuffer line delimiter aware: All client should first normalize what they want to insert or replace. A method IBuffer.normalize() could offer this. An extended request would be to also add the rest of line tracking methods to IBuffer: As offered by IDocument int getLineOfOffset(int offset) int getLineOffset(int line) int getLineLength(int line) IRegion getLineInformation(int line) IRegion getLineInformationOfOffset(int offset) int getNumberOfLines() String[] getLegalLineDelimiters() (all line delimiters in the document) String getLineDelimiter(int line) To implement this, the ILineTracker of org.eclipse.text can be used (but only created on demand).

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/PrimaryWorkingCopyTest.java