Repository navigation
Suppress keybindings and filtering during IME composition - #328269
Merged
Logan Ramos (lramos15) merged 2 commits intoJul 30, 2026
Merged
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: TylerLeonhardtMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes #318977 by preventing workbench keybindings and model-picker filtering from acting on IME composition keystrokes.
Changes:
- Normalizes composing events and centrally suppresses keybinding dispatch.
- Defers action-list filtering until composition commits.
- Adds IME tests and updates keyboard-event fixtures.
Show a summary per file
| File | Description |
|---|---|
src/vs/base/browser/keyboardEvent.ts |
Tracks and normalizes composing events. |
src/vs/base/test/browser/keyboardEvent.test.ts |
Tests composition normalization. |
src/vs/editor/contrib/find/browser/findController.ts |
Removes redundant composition guards. |
src/vs/editor/contrib/rename/browser/rename.ts |
Removes redundant composition guards. |
src/vs/editor/standalone/test/browser/standaloneServices.test.ts |
Updates keyboard-event fixture. |
src/vs/platform/actionWidget/browser/actionList.ts |
Defers filtering and guards direct key handling. |
src/vs/platform/actionWidget/test/browser/actionList.test.ts |
Tests deferred IME filtering. |
src/vs/platform/history/browser/contextScopedHistoryWidget.ts |
Removes redundant composition guards. |
src/vs/platform/keybinding/common/abstractKeybindingService.ts |
Suppresses dispatch during composition. |
src/vs/platform/keybinding/common/keybinding.ts |
Adds composition state to keyboard events. |
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts |
Tests dispatch suppression. |
src/vs/platform/quickinput/browser/quickInputActions.ts |
Relies on centralized suppression. |
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts |
Initializes synthetic event composition state. |
src/vs/workbench/services/keybinding/test/node/fallbackKeyboardMapper.test.ts |
Updates fallback mapper fixtures. |
src/vs/workbench/services/keybinding/test/node/macLinuxKeyboardMapper.test.ts |
Updates macOS/Linux mapper fixtures. |
src/vs/workbench/services/keybinding/test/node/windowsKeyboardMapper.test.ts |
Updates Windows mapper fixtures. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Medium
Drop the `isComposing` member from both `IKeyboardEvent` interfaces and rely on the normalized key code instead. `StandardKeyboardEvent` already reports `KEY_IN_COMPOSITION` for every composing keystroke, so a parallel `isComposing` flag was a second source of truth for the same fact. It also broke the standalone editor build: `@internal` members are stripped from `out-editor-src`, which left `base`'s interface without the property while `platform`'s still required it, so the two `IKeyboardEvent` types stopped being assignable (5 errors in editor-distro). Using the key code fixes that build, keeps `monaco.d.ts` unchanged, and reverts the `isComposing: false` churn from the keyboard mapper tests. Also cancel any in-flight dynamic filter when a composition starts: a request issued for the previous value could otherwise resolve mid-composition and splice and re-layout the list underneath the IME candidate window. Co-authored-by: Copilot <[email protected]> Copilot-Session: c4ba1417-a152-448b-af4b-1a5017b949e8
Benjamin Christopher Simmonds (benibenj)
approved these changes
Jul 30, 2026
Logan Ramos (lramos15)
deleted the
lramos15/agents/investigate-issue-318977-fix
branch
July 30, 2026 21:24
| ContextKeyExpr.notEquals(quickInputTypeContextKeyValue, QuickInputType.QuickWidget), | ||
| inQuickInputContext, | ||
| ContextKeyExpr.not('isComposing') | ||
| inQuickInputContext |
Member
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #318977
Typing pinyin into the chat Model Picker search box and pressing Enter to commit the IME composition also accepted the highlighted model and closed the picker.
Root cause
During an IME composition browsers normally report
keyCode: 229, which VS Code maps toKeyCode.KEY_IN_COMPOSITION— soequals(KeyCode.Enter)isfalseand nothing fires. But some platform/IME combinations report the real key code withisComposing: true, and in that case the keystroke reaches the application even though it belongs to the input method.This isn't specific to the model picker. The same class of bug produced #272407 (macOS Japanese IME: committing a composition also submitted the Create Branch quick input) and #107154 (editor find widget). Each was fixed by adding
ContextKeyExpr.not('isComposing')to one keybinding, so before this PR only 5 call sites in the entire codebase were guarded — every other Enter/Space/arrow handler was still exposed.Fix
Rather than adding a 6th guard, this handles composition at the two points where a keystroke can turn into behavior.
1. Normalize the key code at the source —
src/vs/base/browser/keyboardEvent.tsThis makes the inconsistent browser behavior look like the consistent one, and gives "the IME owns this keystroke" a single representation — the one the editor already checks for. Because it happens in
StandardKeyboardEvent, it fixesequals(),toKeyCodeChord()and the ~237 handlers that comparekeyCodedirectly — including several that a guard onequals()alone would have missed (browserUrlBarWidget,chatInputPart,suggestEnabledInput).No new members are added to either
IKeyboardEventinterface: the normalizedkeyCodeis the signal, so_dispatchand friends simply testkeyCode === KeyCode.KEY_IN_COMPOSITION.2. Make keybinding dispatch agree with itself —
src/vs/platform/keybinding/common/abstractKeybindingService.ts_dispatch,_singleModifierDispatchandsoftDispatchnow apply the same policy.softDispatchmatters: callers such as the terminal use it to ask "will the workbench claim this key?", and a yes there followed by a no in_dispatchwould drop the keystroke entirely, preventing xterm from handing it to the IME.3. Remove the now-dead per-command guards (−19 lines)
The 7 pre-existing
not('isComposing')clauses inquickInputActions,contextScopedHistoryWidget,renameandfindControllerare redundant: a composing event resolves toKEY_IN_COMPOSITION, matches no keybinding, and never reaches itswhenclause.Removing them surfaced a latent bug: the
renameandfindControllerguards depended on a context key that only the workbench ever sets, so they were already no-ops in standalone Monaco. Standalone routes through_dispatch, so it now gets protection it never actually had.The
isComposingcontext key itself is kept — it is user-facing inkeybindings.json.4. Suppress search-as-you-type during composition —
src/vs/platform/actionWidget/browser/actionList.tsSeparate from key dispatch: re-filtering on each intermediate
inputevent splices the list and triggers a re-layout, which resizes and repositions the popup underneath the IME candidate window. Filtering now waits forcompositionend, mirroring the existingcheckImeCompletionStatepattern used by the webview/terminal find widgets. Includes dedupe for the trailinginputevent, since browsers disagree on whether it fires before or aftercompositionend, and cancels any in-flight dynamic filter oncompositionstartso a request issued for the previous value cannot resolve and re-layout mid-composition.Behavior change worth calling out
Keybindings are suppressed for the whole composition, including modified chords — so Ctrl+S is inert while a composition is active. This is deliberate:
isComposingis the browser telling us the IME owns the keystroke, and the risk is asymmetric — a missed Ctrl+S is retried in a second, whereas a spurious Enter creates a branch, sends a prompt or picks the wrong model.Validation
tsc,hygiene,eslintandmonaco-typecheckcleansoftDispatchagreement, and the filter suppression/cancellationsrc/vs/monaco.d.tsis byte-identicalnpm run monaco-compile-checkandnpm run gulp editor-distro(the Monaco Editor CI checks) pass