[BUG] Inconsistent preserveFocus on diff-open calls causes IME composition loss (VS Code extension)
[BUG] Inconsistent preserveFocus on diff-open calls causes IME composition loss (VS Code extension)
Summary
When Claude Code opens a file-edit diff, it always opens a new editor tab (preview:false, hardcoded, no user setting — same underlying behavior as #42288/#52832/#43619). This report focuses on a more severe side effect: on at least one code path, the diff is opened without preserveFocus: true, which steals editor focus away from the chat input. If the user is mid-composition in an IME (Japanese/Chinese/Korean/Vietnamese input), the forced focus change fires compositionend prematurely, committing the unconverted candidate text and silently corrupting/losing what the user was typing.
Evidence (from extension.js, v2.1.211)
Three call sites invoke vscode.diff with distinct option objects:
I = { preview: false, preserveFocus: true } // site 1
b = { preview: false, preserveFocus: true } // site 2
v = { preview: false } // site 3 - preserveFocus NOT set (defaults to false)
Site 3 is the outlier and the likely source of focus theft.
Steps to reproduce
- Set OS/input method to Japanese (or any IME-based language) and open the Claude Code chat panel in VS Code.
- Start typing a message with kanji conversion in progress (composition not yet confirmed).
- While still mid-composition, trigger a file edit from Claude (or have an in-flight edit complete) that opens a new diff tab via the "site 3" path.
- Observe: the in-progress IME candidate is committed/lost as unconverted text, and the diff tab now has focus instead of the chat input.
Expected behavior
All diff-opening code paths should consistently pass preserveFocus: true (matching sites 1 and 2), so opening a diff never steals focus from wherever the user is actively typing.
Suggested fix
Add preserveFocus: true to the options object at site 3, and add a regression test / lint rule ensuring all vscode.diff invocations in this extension share the same focus-handling options.
Related (broader "opens in new tab" complaints, not IME-specific)
- #42288, #52832, #43619 - closed as not planned/duplicate. This report is scoped narrowly to the focus-stealing/IME-corruption consequence, which those threads did not identify.
Environment
- Claude Code VS Code extension: 2.1.211
- OS: Windows 11 Pro
- VS Code: 1.116.0
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗