From 24c092782580dddbb83dc5079c8df4c78f57208f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pereda?= Date: Wed, 2 Aug 2023 11:36:24 +0200 Subject: [PATCH] remove table decoration from previous paragraph (#284) --- .../java/com/gluonhq/richtextarea/model/PieceTable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rta/src/main/java/com/gluonhq/richtextarea/model/PieceTable.java b/rta/src/main/java/com/gluonhq/richtextarea/model/PieceTable.java index c8ee422..9fc20fa 100644 --- a/rta/src/main/java/com/gluonhq/richtextarea/model/PieceTable.java +++ b/rta/src/main/java/com/gluonhq/richtextarea/model/PieceTable.java @@ -326,7 +326,12 @@ public ParagraphDecoration getParagraphDecorationAtCaret(int caretPosition) { } textPosition += piece.length; } - return previousPieceParagraphDecoration(index); + ParagraphDecoration prevDecoration = previousPieceParagraphDecoration(index); + if (prevDecoration.hasTableDecoration()) { + // remove table decoration from the previous paragraph + return ParagraphDecoration.builder().fromDecoration(prevDecoration).tableDecoration(new TableDecoration()).build(); + } + return prevDecoration; } @Override