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 @@ -164,6 +164,15 @@ public void deactivate(SearchOptions searchOption) {
notifyAvailabilityChangedIfNeeded(oldAvailabilities);
}

@Override
public void toggle(SearchOptions searchOption) {
if (isActive(searchOption)) {
deactivate(searchOption);
} else {
activate(searchOption);
}
}

@Override
public boolean isActive(SearchOptions searchOption) {
return searchOptions.contains(searchOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public interface IFindReplaceLogic {
*/
public void deactivate(SearchOptions searchOption);

/**
* Toggles a search option
*
* @param searchOption option
*/
public void toggle(SearchOptions searchOption);

/**
* Registers a listener that is notified whenever the given search option is
* activated or deactivated. The listener is called with {@code true} when the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ private void createCloseTools() {

private void createAreaSearchButton() {
FindReplaceOverlayAction searchInSelectionAction = new FindReplaceOverlayAction(() -> {
activateInFindReplacerIf(SearchOptions.GLOBAL, !findReplaceLogic.isActive(SearchOptions.GLOBAL));
findReplaceLogic.toggle(SearchOptions.GLOBAL);
updateIncrementalSearch();
});
searchInSelectionAction.addShortcuts(KeyboardShortcuts.OPTION_SEARCH_IN_SELECTION);
Expand All @@ -645,7 +645,7 @@ private void createAreaSearchButton() {

private void createRegexSearchButton() {
FindReplaceOverlayAction regexAction = new FindReplaceOverlayAction(() -> {
activateInFindReplacerIf(SearchOptions.REGEX, !findReplaceLogic.isActive(SearchOptions.REGEX));
findReplaceLogic.toggle(SearchOptions.REGEX);
updateIncrementalSearch();
});
regexAction.addShortcuts(KeyboardShortcuts.OPTION_REGEX);
Expand All @@ -663,7 +663,7 @@ private void createRegexSearchButton() {

private void createCaseSensitiveButton() {
FindReplaceOverlayAction caseSensitiveAction = new FindReplaceOverlayAction(() -> {
activateInFindReplacerIf(SearchOptions.CASE_SENSITIVE, !findReplaceLogic.isActive(SearchOptions.CASE_SENSITIVE));
findReplaceLogic.toggle(SearchOptions.CASE_SENSITIVE);
updateIncrementalSearch();
});
caseSensitiveAction.addShortcuts(KeyboardShortcuts.OPTION_CASE_SENSITIVE);
Expand All @@ -677,7 +677,7 @@ private void createCaseSensitiveButton() {

private void createWholeWordsButton() {
FindReplaceOverlayAction wholeWordAction = new FindReplaceOverlayAction(() -> {
activateInFindReplacerIf(SearchOptions.WHOLE_WORD, !findReplaceLogic.isActive(SearchOptions.WHOLE_WORD));
findReplaceLogic.toggle(SearchOptions.WHOLE_WORD);
updateIncrementalSearch();
});
wholeWordAction.addShortcuts(KeyboardShortcuts.OPTION_WHOLE_WORD);
Expand Down
Loading