Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ public void selectParagraph() {
if (p != null) {
int ix = p.index();
TextPos an = TextPos.ofLeading(ix, 0);
TextPos ca = control.getParagraphEnd(ix);
TextPos ca = TextPos.ofLeading(ix + 1, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work if you select the last paragraph in the RTA? You'll be calling TextPos.ofLeading with a paragraph index that is out of range, but maybe it handles it?

I see you added a test for just this case. Good.

control.select(an, ca);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,23 @@ public void selectAll() {
assertEquals(end, sel.getMax());
}

@Test
public void selectParagraph() {
control.appendText("123\n456\n789");
// first line
control.select(TextPos.ZERO);
control.selectParagraph();
SelectionSegment sel = control.getSelection();
assertEquals(TextPos.ZERO, sel.getMin());
assertEquals(TextPos.ofLeading(1, 0), sel.getMax());
// last line, no trailing line separator
control.select(TextPos.ofLeading(2, 0));
control.selectParagraph();
sel = control.getSelection();
assertEquals(TextPos.ofLeading(2, 0), sel.getMin());
assertEquals(new TextPos(2, 3, 2, false), sel.getMax());
}

@Test
public void undo() {
control.appendText("1");
Expand Down