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 @@ -1361,7 +1361,7 @@ private void activateInFindReplaceLogicIf(SearchOptions option, boolean shouldAc
private void decorate() {
if (fIsRegExCheckBox.getSelection()) {
regexOk = SearchDecoration.validateRegex(fFindField.getText(), fFindFieldDecoration);
updateButtonState(regexOk);
updateButtonState(!regexOk);

} else {
fFindFieldDecoration.hide();
Expand Down Expand Up @@ -1406,6 +1406,7 @@ private void assignIDs() {
fReplaceSelectionButton.setData(ID_DATA_KEY, "replaceOne");
fReplaceFindButton.setData(ID_DATA_KEY, "replaceFindOne");
fReplaceAllButton.setData(ID_DATA_KEY, "replaceAll");
fFindNextButton.setData(ID_DATA_KEY, "findNext");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class DialogAccess implements IFindReplaceUIAccess {

private final Button replaceAllButton;

private final Button findNextButton;

DialogAccess(IFindReplaceTarget findReplaceTarget, Dialog findReplaceDialog) {
this.findReplaceTarget= findReplaceTarget;
this.findReplaceDialog= findReplaceDialog;
Expand All @@ -89,6 +91,7 @@ class DialogAccess implements IFindReplaceUIAccess {
replaceButton= widgetExtractor.findButton("replaceOne");
replaceFindButton= widgetExtractor.findButton("replaceFindOne");
replaceAllButton= widgetExtractor.findButton("replaceAll");
findNextButton= widgetExtractor.findButton("findNext");
}

void restoreInitialConfiguration() {
Expand Down Expand Up @@ -205,6 +208,10 @@ public String getSelectedFindText() {
return findCombo.getText().substring(selection.x, selection.y);
}

public Button getReplaceButton() {
return replaceButton;
}

public Combo getFindCombo() {
return findCombo;
}
Expand All @@ -219,6 +226,10 @@ public void performReplace() {
replaceButton.notifyListeners(SWT.Selection, null);
}

public void performFindNext() {
findNextButton.notifyListeners(SWT.Selection, null);
}

@Override
public void performReplaceAndFind() {
replaceFindButton.notifyListeners(SWT.Selection, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,17 @@ public void testRegExSearch_nonIncremental() {
assertEquals(2, (target.getSelection()).y);
}

@Test
public void testReplaceButtonEnabledWithRegexSearched() {
initializeTextViewerWithFindReplaceUI("one two three");

DialogAccess dialog= getDialog();
dialog.setFindText("two");
dialog.select(SearchOptions.REGEX);
dialog.setReplaceText("two2");
dialog.performFindNext();

assertTrue(dialog.getReplaceButton().isEnabled());
}

}
Loading