[BUG] Inconsistent preserveFocus on diff-open calls causes IME composition loss (VS Code extension)

Open Beginner friendly
#77,979 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript, vscode
Domain
desktop, devtools

Research direction

Start with the three vscode.diff call sites described in extension.js, especially site 3 where the options omit preserveFocus. Compare it with sites 1 and 2, then add the suggested regression test or lint coverage so all diff invocations preserve focus. Done means the affected call consistently passes preserveFocus: true and the relevant check passes.

Written by the indexing model from the issue text.

Description

area:ide bug has repro platform:macos platform:vscode platform:windows stale

[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
  1. Set OS/input method to Japanese (or any IME-based language) and open the Claude Code chat panel in VS Code.
  2. Start typing a message with kanji conversion in progress (composition not yet confirmed).
  3. 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.
  4. 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
Dominant language
TypeScript
Stars
147k
Forks
24k
Avg merge
8h 14m
Merged PRs (30d)
18

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.