Skip to content
Merged
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 @@ -16,6 +16,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(NestedRunner.class)
public class UndoManagerTests {
Expand All @@ -40,6 +41,22 @@ public void incoming_change_is_not_merged_after_period_of_user_inactivity() {
assertEquals("", area.getText());
}

@Test // After undo, text insertion point jumps to the start of the text area #780
public void undo_leaves_correct_insertion_point() {
long periodOfUserInactivity = UndoUtils.DEFAULT_PREVENT_MERGE_DELAY.toMillis() + 300L;

write("abc def ");
sleep(periodOfUserInactivity);

write("xyz");
interact(area::undo);

write('g');

sleep(periodOfUserInactivity);
assertTrue(area.getText().endsWith("g"));
}

@Test
public void testUndoWithWinNewlines() {
String text1 = "abc\r\ndef";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ public SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startP
// (prevents a StringIndexOutOfBoundsException because
// end is one char farther than area's length).

if (getLength() < getEndPosition()) {
finalStart = getLength();
finalEnd = getLength();
if (getEndPosition() > 0) {
finalStart = area.getLength();
finalEnd = finalStart;
}
}
}
Expand Down