Skip to content

Commit

Permalink
Find/Replace overlay: immediate replace after selected text #2011
Browse files Browse the repository at this point in the history
Work around for a bug of the Editor's implementation of the
FindReplaceTargetExtension3; when initializing the search with an
already selected string, force the overlay to search for it again so
that the Editor can then later replace it if required.

fixes #2011
  • Loading branch information
Maximilian Wittmer authored and Maximilian Wittmer committed Jul 15, 2024
1 parent 224ee6f commit 0f8541b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ private void updateFromTargetSelection() {
}
searchBar.setText(selectionText);
searchBar.setSelection(0, selectionText.length());
findReplaceLogic.findAndSelect(findReplaceLogic.getTarget().getSelection().x, searchBar.getText());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,18 @@ public void testActivateDialogSelectionActive_withRegExOptionActivated() {
assertThat(fTextViewer.getDocument().get(), is("test ;"));
}

@Test
public void testReplaceIfSelectedOnStart() {
openTextViewer("abcdefg");
fTextViewer.setSelection(new TextSelection(2, 2));
initializeFindReplaceUIForTextViewer();

dialog.setReplaceText("aa");
dialog.performReplace();

assertThat(fTextViewer.getDocument().get(), is("abaaefg"));
}

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

0 comments on commit 0f8541b

Please sign in to comment.