Find/Replace overlay: fix whole-word button enablement lagging by one keystroke#4165
Merged
HeikoKlare merged 1 commit intoJul 6, 2026
Conversation
… keystroke The modify listener in createSearchBar() called wholeWordSearchButton.setEnabled(findReplaceLogic.isAvailable(WHOLE_WORD)) before updateIncrementalSearch(). Because updateIncrementalSearch() is what pushes the new search text into FindReplaceLogic.setFindString(), the isAvailable check always operated on the previous find string, causing the enabled state of the whole-word button to lag one keystroke behind. Move the setEnabled call to after updateIncrementalSearch() so that isAvailable(WHOLE_WORD) evaluates the current, already-updated find string. Add a regression test that sets a multi-word search term and immediately verifies the button is disabled, then sets a single-word term and verifies it is re-enabled, all without an intervening keystroke. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a UI state update ordering issue in the Find/Replace overlay so the “Whole word” toggle’s enabled/disabled state reflects the current search text immediately (instead of lagging by one keystroke), and adds a regression test to prevent reintroducing the behavior.
Changes:
- Reorders the search field modify listener logic so
updateIncrementalSearch()(which updatesFindReplaceLogic’s find string) runs before queryingisAvailable(WHOLE_WORD). - Adds a regression test verifying whole-word enablement flips immediately when changing between a non-word (contains whitespace) and a single word.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java |
Updates modify-listener ordering so whole-word availability is computed from the current find string. |
tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlayTest.java |
Adds a regression test asserting whole-word enablement updates immediately after setting the find text. |
💡 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 modify listener in
createSearchBar()calledwholeWordSearchButton.setEnabled(findReplaceLogic.isAvailable(WHOLE_WORD))beforeupdateIncrementalSearch(). BecauseupdateIncrementalSearch()is responsible for pushing the new text intoFindReplaceLogicviasetFindString(), the availability check always operated on the previous find string. As a result, the enabled state of the whole-word button was always one keystroke behind the actual content of the search field.The fix moves
setEnabledto afterupdateIncrementalSearch()so thatisAvailable(WHOLE_WORD)evaluates the current, already-updated find string.A regression test is added to
FindReplaceOverlayTestthat sets a multi-word search term and immediately asserts the button is disabled, then sets a single-word term and asserts it is re-enabled -- both without an intervening keystroke.Before
After
This change was extracted from PR #4164 to keep one concern per PR: #4164
This change was created with the help of GitHub Copilot.