Find/replace overlay: fix wrong initialization of search state#4151
Merged
HeikoKlare merged 1 commit intoJul 6, 2026
Merged
Conversation
Contributor
83834e5 to
4d38526
Compare
4d38526 to
3a92fb9
Compare
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.
3a92fb9 to
ed1ed4d
Compare
There was a problem hiding this comment.
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 mirroringWHOLE_WORD). - Make the overlay’s
findReplaceLogicreferencefinaland typed asIFindReplaceLogic, 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.
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.
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.