On Fri, 8 Apr 2022 12:13:03 GMT, Tejesh R <d...@openjdk.java.net> wrote:

>> When you do out.write(array, last, counter - last); in write(Writer out, 
>> Document doc, int pos, int len) method, what is being written? Is it /r/r/n 
>> or /n/r/n presently?
>
> Finally its /n/r/n....... I mentioned /r/r/n because that was the output 
> string from `getText()` method to `setText()` method......

Let me summarise:

Initially, `getText()` wrote out `\r\r\n` for the sequence of `\r\n` in the 
document.

Then `setText()` converted `\r\r\n` to `\n\r\n` or rather `\n\n` which resulted 
in the additional blank line in the editor.

The updated code makes sure the additional `\r` isn't added when the text 
already contains `\r` as part of new line sequence.

Is it correct?

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

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

Reply via email to