Skip to content

Commit 42fd4eb

Browse files
author
Andy Goryachev
committed
8369085: RichTextArea SELECT_PARAGRAPH to include line separator
Reviewed-by: kcr
1 parent 47d9dcc commit 42fd4eb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/RichTextAreaBehavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ public void selectParagraph() {
910910
if (p != null) {
911911
int ix = p.index();
912912
TextPos an = TextPos.ofLeading(ix, 0);
913-
TextPos ca = control.getParagraphEnd(ix);
913+
TextPos ca = TextPos.ofLeading(ix + 1, 0);
914914
control.select(an, ca);
915915
}
916916
}

modules/jfx.incubator.richtext/src/test/java/test/jfx/incubator/scene/control/richtext/RichTextAreaTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,23 @@ public void selectAll() {
642642
assertEquals(end, sel.getMax());
643643
}
644644

645+
@Test
646+
public void selectParagraph() {
647+
control.appendText("123\n456\n789");
648+
// first line
649+
control.select(TextPos.ZERO);
650+
control.selectParagraph();
651+
SelectionSegment sel = control.getSelection();
652+
assertEquals(TextPos.ZERO, sel.getMin());
653+
assertEquals(TextPos.ofLeading(1, 0), sel.getMax());
654+
// last line, no trailing line separator
655+
control.select(TextPos.ofLeading(2, 0));
656+
control.selectParagraph();
657+
sel = control.getSelection();
658+
assertEquals(TextPos.ofLeading(2, 0), sel.getMin());
659+
assertEquals(new TextPos(2, 3, 2, false), sel.getMax());
660+
}
661+
645662
@Test
646663
public void undo() {
647664
control.appendText("1");

0 commit comments

Comments
 (0)