Find/replace: add test for whole-word availability with unavailable regex#4178
Merged
HeikoKlare merged 1 commit intoJul 10, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a UI/logic inconsistency in the text editor Find/Replace controller (FindReplaceLogic) where Whole Word remained available when Regex mode was active on targets that don’t support regex, even though the options are mutually exclusive. It also adds a regression test intended to cover that scenario.
Changes:
- Fix
WHOLE_WORDavailability logic to depend onisActive(REGEX)(notisAvailableAndActive(REGEX)), so Whole Word is disabled whenever Regex is active. - Add a new JUnit test in
FindReplaceLogicTestto validate Whole Word becomes unavailable when Regex is active without regex support.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogic.java | Corrects whole-word availability check to key off regex activation state rather than availability+activation. |
| tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicTest.java | Adds a regression test for whole-word availability when regex is active on non-regex-capable targets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d076656 to
0c602b4
Compare
Contributor
…x support Whole-word search and regex mode are mutually exclusive when regex is effectively active. However, activating regex mode on a target that does not support regex has no effective impact -- the option is activated but not available, so it must not restrict other options like whole-word search. This is already the correct behavior: the availability check for whole-word uses isAvailableAndActive(REGEX), which requires both availability and activation, so merely activating regex on a non-capable target leaves whole-word unaffected. A test is added to explicitly document and protect this invariant. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0c602b4 to
0e6e1b6
Compare
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a test to document and protect the invariant that activating an unavailable search option must not restrict other options.
Specifically, whole-word search and regex mode are mutually exclusive — but only when regex is effectively active (i.e., both activated and available on the current target). Activating regex mode on a target that does not support regex has no effective impact and must therefore leave the whole-word option unaffected. This is already the correct behavior in
FindReplaceLogic, but was previously untested.This change was extracted from #4176 to keep one concern per PR.
This change was created with the help of GitHub Copilot.