From 1a3bda947993ee7c505116ff4bb4d4ca9caa5506 Mon Sep 17 00:00:00 2001 From: Jurgen Date: Tue, 25 Aug 2020 13:44:12 +0200 Subject: [PATCH] Fix multi paragraph insert creation (#951) --- .../java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java index 7516c632f..d6533c202 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java @@ -127,6 +127,9 @@ public static ReadOnlyStyledDocument fromString(String * @param The type of the style of individual segments. */ public static ReadOnlyStyledDocument fromSegment(SEG segment, PS paragraphStyle, S style, SegmentOps segmentOps) { + if ( segment instanceof String && segmentOps instanceof TextOps ) { + return fromString( (String) segment, paragraphStyle, style, (TextOps) segmentOps ); + } Paragraph content = new Paragraph(paragraphStyle, segmentOps, segment, style); List> res = Collections.singletonList(content); return new ReadOnlyStyledDocument<>(res);