Repository navigation
Reimplement MirthPlainDocument without Sun-derived code - #484
Open
tonygermano wants to merge 2 commits into
Open
tonygermano wants to merge 2 commits into
tonygermano wants to merge 2 commits into
Conversation
MirthPlainDocument differs from PlainDocument mainly in treating a lone CR as a line break, so CR-delimited HL7 shows one segment per line, while CRLF stays a single break. Pin down that behavior before the class is rewritten: line boundaries for CR, LF, CRLF and LFCR, joining and splitting CRLF through edits, one root element change per insert, removal across lines, undo/redo, the unchanged text, and the tab size of 4. Also cover text in other scripts: right-to-left Hebrew and Arabic lines with their bidi levels, mixed-direction lines, bidi control characters, CJK and supplementary characters, and input method composed text. Issue: OpenIntegrationEngine#473 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Tony Germano <tony@germano.name>
MirthPlainDocument was a copy of the Java 1.5 PlainDocument source with its Sun proprietary header, which is not compatible with the project's license. The only behavior it changed was to break lines on a lone CR as well as LF, plus a default tab size of 4 instead of 8. Extend PlainDocument instead and keep only those two changes. PlainDocument builds its line map from a single read of the inserted text, splitting after each LF. The document's content now reports lone CRs as LFs for that one read, on a copy of the text, so PlainDocument puts the breaks in the same places while the stored text stays unchanged and each insert still produces a single root element change. The translation is tied to the inserting thread, since getText does not take the document lock and another thread could otherwise make that read. Drop the constructor that takes a Content, since nothing uses it and the line breaks depend on the document's own content. Move the class out of the third-party org.syntax.jedit package into com.mirth.connect.client.ui.components, next to MirthSyntaxTextArea, which uses it through SyntaxDocument. Issue: OpenIntegrationEngine#473 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Tony Germano <tony@germano.name>
tonygermano
requested review from
NicoPiel,
gibson9583,
jonbartels,
kayyagari,
kpalang,
mgaffigan and
ssrowe
October 11, 2026 08:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #473
org.syntax.jedit.MirthPlainDocumentwas a 2007 copy of the Java 1.5javax.swing.text.PlainDocumentsource, and it still carried Sun's "PROPRIETARY/CONFIDENTIAL" header, which is not compatible with the project's MPL-2.0 license. This PR replaces it with an original implementation that extendsPlainDocumentinstead of copying it.What the old copy changed
Compared with the JDK 17 and 25
PlainDocument(which are identical apart from one javadoc tag), the copy only changed two things:Everything else was the JDK's code, plus private copies of two package-private helpers it needed because it lived outside
javax.swing.text.How the new class works
MirthPlainDocumentnow extendsPlainDocumentand sets the tab size to 4.PlainDocumentfinds line breaks with a single read of the inserted text, splitting after each LF. The document's content is a smallGapContentsubclass that reports each lone CR as an LF for that one read only, using a copy of the text.PlainDocumenttherefore puts the breaks in the same places, the stored text is unchanged, and each insert still produces a single root element change, whichJEditTextAreaandSyntaxDocumentrely on.getText, painting, tokenizing, and the bidi and multibyte checks inAbstractDocumentalways see the real characters.org.syntax.jeditpackage tocom.mirth.connect.client.ui.components, next toMirthSyntaxTextArea.MirthPlainDocument(Content)constructor was removed.Commits
Known behavior (unchanged)
The old class did both of these too:
In both cases the stored text is correct, so only the display is affected.
Testing
./gradlew :client:testpasses.🤖 Generated with Claude Code