diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java index fe2647194..ac689a70b 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java @@ -156,7 +156,8 @@ public Bounds getRangeBoundsOnScreen(int from, int to) { PathElement[] rangeShape = getRangeShape(from, to); // switch out shapes to calculate the bounds on screen - List selShape = selectionShape.getElements(); + // Must take a copy of the list contents, not just a reference: + List selShape = new ArrayList<>(selectionShape.getElements()); selectionShape.getElements().setAll(rangeShape); Bounds localBounds = selectionShape.getBoundsInLocal(); Bounds rangeBoundsOnScreen = selectionShape.localToScreen(localBounds);