RFR: 8180276: JTextPane getText return extra when mixed with methods of Document [v3]

Tejesh R duke at openjdk.java.net
Fri Apr 8 12:02:41 UTC 2022


On Fri, 8 Apr 2022 11:43:26 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> But should /r/r/n cause 2 line feeds? /r should be just carriage return to cause caret to move from last column to first, why it is inserting new line?
>
> It is common to treat `\r` as new line if it's not followed by `\n`. In a visual editor `\r` doesn't do anything.
> 
> Yet it's an interesting detail that wasn't covered in the initial evaluation.

> But should /r/r/n cause 2 line feeds? /r should be just carriage return to cause caret to move from last column to first, why it is inserting new line?

\r is converted to \n in setText method....... To be specific, in `read(Reader in, Document doc, int pos)` method of DefaultEditorKit class......

-------------

PR: https://git.openjdk.java.net/jdk/pull/8122



More information about the client-libs-dev mailing list