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

2022-04-08 Thread Alexey Ivanov
On Fri, 8 Apr 2022 12:13:03 GMT, Tejesh R 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 t

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 11:59:19 GMT, Tejesh R wrote: >> So, that means presently it is writing /n/r/n not /r/r/n, right? > > Initially it is /r/r/n from `getText()` of pane0, later it is /n/r/n from > `setText()` When you do out.write(array, last, counter - last); in write(Writer out, Document

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 12:08:07 GMT, Prasanta Sadhukhan wrote: >> Initially it is /r/r/n from `getText()` of pane0, later it is /n/r/n from >> `setText()` > > When you do out.write(array, last, counter - last); in write(Writer out, > Document doc, int pos, int len) method, what is being writte

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 11:56:36 GMT, Prasanta Sadhukhan 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? >> >> \r is converted to \n in setText method... To be specific, in >>

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 11:54:02 GMT, Tejesh R wrote: >> 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?

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 11:43:26 GMT, Alexey Ivanov 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 > vis

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

2022-04-08 Thread Alexey Ivanov
On Fri, 8 Apr 2022 11:31:07 GMT, Prasanta Sadhukhan wrote: >> No, presently it was writing /r/r/n and with fix it will write /r/n for >> every line ending.. /r was causing for carriage return and /r/n for an >> extra empty line on Text pane... > > But should /r/r/n cause 2 line feeds?

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 11:28:26 GMT, Tejesh R wrote: >> So, presently it was writing /r/n/r/n and with fix, it will write >> /r/n, right? > > No, presently it was writing /r/r/n and with fix it will write /r/n for every > line ending.. /r was causing for carriage return and /r/n for an extra >

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 11:25:36 GMT, Prasanta Sadhukhan wrote: >>> 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? >> >> Yes. > > So, presently it was writing /r/n/r/n and with fix, it will write > /r/n, r

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 10:14:58 GMT, Tejesh R wrote: >> 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 { >> } > >> ok, so yo

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 09:02:53 GMT, Prasanta Sadhukhan wrote: > 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? Yes. - PR: https://git.openjdk.java.net/jdk/pull/8122

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 08:49:36 GMT, Tejesh R wrote: >> src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java line >> 350: >> >>> 348: } >>> 349: } >>> 350: out.write(endOfLine); >> >> It seems in windows,

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

2022-04-08 Thread Tejesh R
On Fri, 8 Apr 2022 08:38:20 GMT, Prasanta Sadhukhan wrote: >> Tejesh R has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Java coding style fix > > src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java line > 350: > >> 34

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

2022-04-08 Thread Prasanta Sadhukhan
On Fri, 8 Apr 2022 06:55:34 GMT, Tejesh R wrote: >> getText function returned extra endOfLine when appended. The reason was in >> `EditorEditorKit` class, `write(Writer out, Document doc, int pos, int len)` >> method, where translation happens from buffer to Out(Writer Object) if >> endOfLine

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

2022-04-07 Thread Tejesh R
> getText function returned extra endOfLine when appended. The reason was in > `EditorEditorKit` class, `write(Writer out, Document doc, int pos, int len)` > method, where translation happens from buffer to Out(Writer Object) if > endOfLine is other than '\n' ( which is '\r\n' in windows). In or