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

Tejesh R duke at openjdk.java.net
Wed Apr 6 10:09:01 UTC 2022


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 order to write each line till End of line, the string till '\n' is written including '\r' and again endOfLine is written which results in extra Carriage Return. To solve this issue, a Condition is added which checks if previous character to '\n' is '\r', if true then whole string except Carriage Return ('\r') is written, else whole string till before '\n' is written.

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

Commit messages:
 - Fix for the Bug - Checking Condition added for \r
 - Merge branch 'master' of github.com:TejeshR13/jdk
 - Merge branch 'openjdk:master' into master
 - Merge remote-tracking branch 'upstream/master'
 - Merge remote-tracking branch 'upstream/master'
 - Merge branch 'master' of github.com:TejeshR13/jdk
 - Initial Commit.

Changes: https://git.openjdk.java.net/jdk/pull/8122/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8122&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8180276
  Stats: 7 lines in 1 file changed: 6 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8122.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8122/head:pull/8122

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



More information about the client-libs-dev mailing list