On Mon, 11 Apr 2022 10:15:43 GMT, Tejesh R <d...@openjdk.java.net> wrote:
> > > What happens if you add `\r` to an arbitrary location in text? > > > What happens if you read in such a text? > > > > > > It doesn't matter, since the data is appended only if '\n' is present when > > EndofLine is '\r\n'...... > > I'm not as sure… Well, yes, the text will be written out like expected and > `\r` character will be preserved. Yet when such a text will be read in, the > stranded `\r` will be converted to `\n` which will create an unexpected line > break. Or am I wrong? I edited your test case at line 119: pane0.appendLine("MyJTextPane using append()\r and then calling setText()"); And it creates a new line break after `append()` in the first `JTextPane`. > > > > What happens if you add `\r` to an arbitrary location in text? > > > > What happens if you read in such a text? > > > > > > > > > It doesn't matter, since the data is appended only if '\n' is present > > > when EndofLine is '\r\n'...... > > > > > > I'm not as sure… Well, yes, the text will be written out like expected and > > `\r` character will be preserved. Yet when such a text will be read in, the > > stranded `\r` will be converted to `\n` which will create an unexpected > > line break. Or am I wrong? > > In `read(Reader in, Document doc, int pos)`, of DefaultEditorKit class, the > logic states this `// Read in a block at a time, mapping \r\n to \n, as well > as single // \r's to \n's. If a \r\n is encountered, \r\n will be set as the > // newline string for the document, if \r is encountered it will // be set as > the newline character, otherwise the newline property // for the document > will be removed.` Is it a bug then? The test case in the bug description behaves according to the spec too: `\r` gets converted to `\n`. ------------- PR: https://git.openjdk.java.net/jdk/pull/8122