Skip to content

Find/replace overlay: fix wrong initialization of search state#4151

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-initialization
Jul 6, 2026
Merged

Find/replace overlay: fix wrong initialization of search state#4151
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-initialization

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The search-in-selection option was accidentally initialized in the UI with the state of the whole-word option in the underlying logic object. This had no visible negative effect because the values are initialized during overlay creation with a fitting initial state.

Still, this change corrects that semantic inconsistency. It also make the FindReplaceLogic of the overlay immutable as it will actually not be modified throughout the overlay's lifecycle. A test for the inverse behavior of the global search option is added.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ±0     855 suites  ±0   48m 54s ⏱️ - 3m 12s
 8 103 tests +1   7 860 ✅ +1  243 💤 ±0  0 ❌ ±0 
20 211 runs  +3  19 557 ✅ +3  654 💤 ±0  0 ❌ ±0 

Results for commit ed1ed4d. ± Comparison against base commit 736f3f9.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the findreplace-initialization branch from 83834e5 to 4d38526 Compare July 6, 2026 06:41
@HeikoKlare HeikoKlare marked this pull request as ready for review July 6, 2026 06:41
@HeikoKlare HeikoKlare force-pushed the findreplace-initialization branch from 4d38526 to 3a92fb9 Compare July 6, 2026 11:27
@HeikoKlare HeikoKlare changed the title Fix wrong initialization of find/replace overlay search state Find/replace overlay: fix wrong initialization of search state Jul 6, 2026
The search-in-selection option was accidentally initialized in the UI
with the state of the whole-word option in the underlying logic object.
This had no visible negative effect because the values are initialized
during overlay creation with a fitting initial state.

Still, this change corrects that semantic inconsistency. It also make
the FindReplaceLogic of the overlay immutable as it will actually not be
modified throughout the overlay's lifecycle. A test for the inverse
behavior of the global search option is added.

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 corrects the initialization semantics of the Find/Replace overlay’s “search in selection” UI toggle so it reflects the actual search scope state (inverse of SearchOptions.GLOBAL). It also tightens the overlay’s ownership of its logic object by making the findReplaceLogic reference immutable (final) and adds a regression test around the global/selection scope inversion behavior.

Changes:

  • Fix initial selection state of the “search in selection” toggle to be !isActive(SearchOptions.GLOBAL) (instead of incorrectly mirroring WHOLE_WORD).
  • Make the overlay’s findReplaceLogic reference final and typed as IFindReplaceLogic, returning it from a creation helper.
  • Add a test that exercises selecting/unselecting the global search option via the overlay UI access layer.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlayTest.java Adds a test validating the global vs. “search in selection” inversion behavior through the UI test abstraction.
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java Fixes initial toggle state for search-in-selection and makes the logic reference final via IFindReplaceLogic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HeikoKlare HeikoKlare merged commit 0ff741f into eclipse-platform:master Jul 6, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the findreplace-initialization branch July 6, 2026 12:40
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