RFR: 8180276: JTextPane getText return extra when mixed with methods of Document [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.java.net
Fri Apr 8 09:06:36 UTC 2022
On Fri, 8 Apr 2022 08:49:36 GMT, Tejesh R <duke at openjdk.java.net> wrote:
>> src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java line 350:
>>
>>> 348: }
>>> 349: }
>>> 350: out.write(endOfLine);
>>
>> It seems in windows, we use EndOfLineStringProperty property as
>> [CRLF](https://github.com/openjdk/jdk/blob/f1b6e3ea16f06bc57e8e905fb115650e6c4ad98f/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java#L286)
>> and `endOfLine ` is using the above property `EndOfLineStringProperty` so
>> when you write out.write(endOfLine) will it not write \r\n again?
>
> Yes, Write function copies string without endOfLine, and endOfLine is appended to it after the whole string is copied.
> Before also it was copying string without endOfLine which included '\r', now this logic copies string characters before '\r' and then appends endOfLine.
ok, so you are telling out.write(array, last, counter - last - 1) will write till \r\n and out.write(endOfLine) will write \r\n, is it?
ANyway, you need to modify this change as per coding style which is
else {
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/8122
More information about the client-libs-dev
mailing list