Fix RawText.getLineDelimiter() for empty first line
Bug: 456776 Change-Id: Iae50be89ea6d5aee33bd938a937ac5ca578aabca Signed-off-by: Frank Wagner <frank.wagner@fr.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
05078f5de1
commit
e09e7c064e
|
@ -230,6 +230,13 @@ public void testLineDelimiter() throws Exception {
|
|||
assertFalse(rt.isMissingNewlineAtEnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineDelimiter2() throws Exception {
|
||||
RawText rt = new RawText(Constants.encodeASCII("\nfoo"));
|
||||
assertEquals("\n", rt.getLineDelimiter());
|
||||
assertTrue(rt.isMissingNewlineAtEnd());
|
||||
}
|
||||
|
||||
private static RawText t(String text) {
|
||||
StringBuilder r = new StringBuilder();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
|
|
|
@ -289,7 +289,7 @@ public String getLineDelimiter() {
|
|||
int e = getEnd(0);
|
||||
if (content[e - 1] != '\n')
|
||||
return null;
|
||||
if (content.length > 1 && content[e - 2] == '\r')
|
||||
if (content.length > 1 && e > 1 && content[e - 2] == '\r')
|
||||
return "\r\n"; //$NON-NLS-1$
|
||||
else
|
||||
return "\n"; //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in New Issue