Skip to content

Find/Replace overlay: fix whole-word button enablement lagging by one keystroke#4165

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/whole-word-button-enablement-lag
Jul 6, 2026
Merged

Find/Replace overlay: fix whole-word button enablement lagging by one keystroke#4165
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/whole-word-button-enablement-lag

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The modify listener in createSearchBar() called wholeWordSearchButton.setEnabled(findReplaceLogic.isAvailable(WHOLE_WORD)) before updateIncrementalSearch(). Because updateIncrementalSearch() is responsible for pushing the new text into FindReplaceLogic via setFindString(), 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 setEnabled to after updateIncrementalSearch() so that isAvailable(WHOLE_WORD) evaluates the current, already-updated find string.

A regression test is added to FindReplaceOverlayTest that 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

whole_word_broken

After

whole_word_fixed

This change was extracted from PR #4164 to keep one concern per PR: #4164

This change was created with the help of GitHub Copilot.

… 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>
@HeikoKlare HeikoKlare marked this pull request as ready for review July 6, 2026 08:53
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ±0     855 suites  ±0   1h 4m 9s ⏱️ + 12m 47s
 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 021ac3a. ± Comparison against base commit 9d551a5.

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

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 updates FindReplaceLogic’s find string) runs before querying isAvailable(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.

@HeikoKlare HeikoKlare merged commit c6c5025 into eclipse-platform:master Jul 6, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the fix/whole-word-button-enablement-lag branch July 6, 2026 12:43
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