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 8, 2024
1 parent 7118f66 commit d2b7245
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 @@ -874,6 +874,7 @@ private void updateFromTargetSelection() {
} else {
searchBar.setText(initText);
searchBar.setSelection(0, initText.length());
findReplaceLogic.findAndSelect(findReplaceLogic.getTarget().getSelection().x, searchBar.getText());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ public void testActivateDialogWithSelectionActive() {
assertThat(fTextViewer.getDocument().get(), is("text" + System.lineSeparator() + System.lineSeparator()));
}

@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 d2b7245

Please sign in to comment.