On Mon, 11 Apr 2022 10:10:07 GMT, Alexey Ivanov <aiva...@openjdk.org> 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? 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. ` ------------- PR: https://git.openjdk.java.net/jdk/pull/8122