Skip to content

fix: avoid refocusing find input during IME composition - #320898

Merged
Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
wibaek:fix/webview-find-ime-composition
Sep 6, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
wibaek:fix/webview-find-ime-composition

Conversation

@wibaek

@wibaek Wibaek Park (wibaek) commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #320869

What changed?
Updated the shared find input flow so input events fired from compositionend can update search state without immediately restoring focus to the find box (FindInput.onInput now carries { fromCompositionEnd }). Also added a guard so focusFindBox() does not refocus the find input while an IME composition session is still active.

Why?
focusFindBox() blurs and refocuses the find input (bouncing through the next-match button). When this runs for the input fired at compositionend — or when an async find result arrives while the next character is already composing — the focus change aborts the active IME composition. Korean IME fires compositionend at every syllable boundary, so characters were dropped or corrupted while typing. The search value is still processed as before; only the focus churn around composition is skipped.

How I tested this:
Reproduced the original bug and verified the fix manually with ./scripts/code-web.sh: typing Korean (e.g. 안녕하세요) in the markdown preview find box corrupted characters before this change and is clean after. (Tested on web because webview find is not functional in local desktop builds — stock Electron lacks the findInFrame patch, see #222244.)
Verified English typing, Enter navigation, and find history behavior are unchanged.
npm run compile-check-ts-native and ESLint on the changed files pass.

Before / after
Before:

Before.Current.mov

After:

After.mov

Copilot AI review requested due to automatic review settings June 11, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves IME (Input Method Editor) handling in the find widget by adding composition-aware input events and avoiding focus changes during IME sessions.

Changes:

  • Add a typed payload to FindInput.onInput to indicate whether the change came from compositionend.
  • Update SimpleFindWidget to conditionally refocus the find box based on IME/composition state.
  • Prevent focusFindBox() from running while an IME session is in progress.

Reviewed changes

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

File Description
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts Avoids refocusing the find box during/around IME composition to prevent disruptive focus churn.
src/vs/base/browser/ui/findinput/findInput.ts Enriches input events with composition provenance so callers can treat IME completion differently.

@wibaek

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@wibaek

Copy link
Copy Markdown
Contributor Author

Dmitriy Vasyura (@dmitrivMS) 🥹🥹

@wibaek

Copy link
Copy Markdown
Contributor Author

Hi Dmitriy Vasyura (@dmitrivMS), could you please review this PR when you have a chance and let me know if it’s ready to be merged or if anything needs to be revised?

Track find input events fired from compositionend so IME-completed input can update search state without immediately restoring focus. Also avoid focus restoration while an IME session is still active.
@wibaek
Wibaek Park (wibaek) force-pushed the fix/webview-find-ime-composition branch from 667f4c1 to adab749 Compare September 4, 2026 17:14
Wibaek Park (wibaek) and others added 4 commits September 6, 2026 01:07
Observe calls to the real focus methods instead of DOM focus events, which may not be emitted by inactive Electron test windows. Preserve IME regression coverage and normal focus ordering.

Co-authored-by: Copilot <[email protected]>
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 3d7cfab into microsoft:main Sep 6, 2026
30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 6, 2026
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 23, 2026
…0898)

* fix: avoid refocusing find input during IME composition

Track find input events fired from compositionend so IME-completed input can update search state without immediately restoring focus. Also avoid focus restoration while an IME session is still active.

* test(webview): cover IME focus suppression in find widget

* test(webview): make find focus assertions work in Electron

Observe calls to the real focus methods instead of DOM focus events, which may not be emitted by inactive Electron test windows. Preserve IME regression coverage and normal focus ordering.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Dmitriy Vasyura <[email protected]>
Co-authored-by: Copilot <[email protected]>
(cherry picked from commit 3d7cfab)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Korean IME input is dropped or corrupted in Markdown preview Cmd+F find box

5 participants