Skip to content

Commit 740e24c

Browse files
authored
Cleanup remove selection (#1270)
1 parent 6947aaa commit 740e24c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,12 @@ public final boolean addSelection(Selection<PS, SEG, S> selection) {
473473
}
474474

475475
public final boolean removeSelection(Selection<PS, SEG, S> selection) {
476-
if (selection != caretSelectionBind.getUnderlyingSelection()) {
477-
return selectionSet.remove(selection);
476+
if (selection != caretSelectionBind.getUnderlyingSelection() && selectionSet.remove(selection)) {
477+
for (int p = selection.getStartParagraphIndex(); p <= selection.getEndParagraphIndex(); p++) {
478+
virtualFlow.getCell(p).getNode().selectionsProperty().remove(selection);
479+
}
480+
selection.dispose();
481+
return true;
478482
} else {
479483
return false;
480484
}

0 commit comments

Comments
 (0)