Skip to content

Commit

Permalink
Find/Replace: add test case for find string initialization with regex
Browse files Browse the repository at this point in the history
When opening the FindReplaceOverlay or FindReplaceDialog with regex
option enabled, the current selection in the target editor is escaped to
represent a regex before being inserted into the find input field. This
adds an according test case.
  • Loading branch information
HeikoKlare committed Jul 11, 2024
1 parent 4a34e1c commit bb479a8
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ public void testSelectionOnOpenSetsScopedMode() {
assertScopeActivationOnTextInput("hello\nworld");
}

@Test
public void testActivateDialogSelectionActive_withRegExOptionActivated() {
openTextViewer("test text.*;");
initializeFindReplaceUIForTextViewer();
dialog.select(SearchOptions.REGEX);
fTextViewer.setSelection(new TextSelection("test ".length(), "text.*".length()));
reopenFindReplaceUIForTextViewer();
dialog.assertSelected(SearchOptions.REGEX);
assertEquals("text\\.\\*", dialog.getFindText());

dialog.performReplaceAll();
assertThat(fTextViewer.getDocument().get(), is("test ;"));
}

protected AccessType getDialog() {
return dialog;
}
Expand Down

0 comments on commit bb479a8

Please sign in to comment.