microsoft / microsoft/vscode

Japanese IME reconversion at caret (no selection) duplicates committed text with EditContext

Open
#324,435 0 comments 0 reactions 1 assignee Claimed by @aiday-mar View on GitHub
bug editor-input-IME
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Does this issue occur when all extensions are disabled?: Yes

- VS Code Version: 1.127.0
- OS Version: Windows 11 Pro 10.0.26200

## Summary

With the EditContext-based text input (default `editor.editContext: true`), Japanese IME **reconversion of already-committed text triggered at the caret position (no selection)** inserts the reconverted text instead of replacing the original, resulting in duplicated text. Reconversion **with an explicit selection works correctly** (the selection is replaced).

Reproduces with **Microsoft IME** (built-in) and other TSF-based IMEs, so this is not specific to a particular IME. The same operations work correctly in Notepad and other standard TSF applications.

## Steps to Reproduce

1. Windows, Japanese Microsoft IME active, open any text file in the editor.
2. Type `・・・` (three middle dots), convert with Space to `…`, and commit with Enter. The editor now contains the committed text `…`.
3. Place the caret immediately after `…` **without selecting it**.
4. Press the **Henkan (Convert) key** to reconvert the committed text. The IME shows reconversion candidates.
5. Commit a candidate (Enter).

**Expected**: the original `…` is replaced by the chosen candidate (this is what happens in Notepad, and in VS Code when the text is explicitly selected before pressing Henkan).

**Actual**: the chosen candidate is inserted at the caret, and the original text remains — e.g. `…` becomes `……`.

## Notes

- Selection-based reconversion (select `…`, then press Henkan) replaces correctly, so the defect seems limited to the caret-position reconversion path, where the IME sets the selection over the target range via TSF (`SetSelection`) inside its edit session before starting the composition. TSF-level instrumentation on our side shows the IME's composition range correctly covers the original text (`GetSelection`/`GetRange` both report the covering range), yet the editor applies the composition as an insertion.
- Possibly related: #238643 (reconversion itself was fixed by EditContext), #320074 (duplication when moving the caret before conversion during composition).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.