Skip to content

Find/replace: add test for whole-word availability with unavailable regex#4178

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-whoword-regex-fix
Jul 10, 2026
Merged

Find/replace: add test for whole-word availability with unavailable regex#4178
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-whoword-regex-fix

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_WORD availability logic to depend on isActive(REGEX) (not isAvailableAndActive(REGEX)), so Whole Word is disabled whenever Regex is active.
  • Add a new JUnit test in FindReplaceLogicTest to 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.

@HeikoKlare HeikoKlare force-pushed the findreplace-whoword-regex-fix branch from d076656 to 0c602b4 Compare July 10, 2026 09:02
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ±0     855 suites  ±0   52m 39s ⏱️ - 1m 51s
 8 111 tests +1   7 868 ✅ +1  243 💤 ±0  0 ❌ ±0 
20 235 runs  +3  19 581 ✅ +3  654 💤 ±0  0 ❌ ±0 

Results for commit 0e6e1b6. ± Comparison against base commit f66c97d.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare marked this pull request as ready for review July 10, 2026 09:53
…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>
@HeikoKlare HeikoKlare force-pushed the findreplace-whoword-regex-fix branch from 0c602b4 to 0e6e1b6 Compare July 10, 2026 12:23
@HeikoKlare HeikoKlare changed the title Find/Replace: fix whole-word option staying enabled when regex is activated Find/replace: add test for whole-word availability with unavailable regex Jul 10, 2026
@HeikoKlare HeikoKlare merged commit f4db045 into eclipse-platform:master Jul 10, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the findreplace-whoword-regex-fix branch July 10, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants