#10100·Vim

Multi-character IME commit inserts after selection instead of replacing it

Author: lxl66566Created Sep 30, 2026Updated Sep 30, 2026

Describe the bug

This is a follow-up to issue #3952 , the bug still exists seven years later.

To Reproduce

  1. Enter insert mode.
  2. Select existing text in the editor
  3. Type with an IME and commit a multi-character string (e.g. "你好") with space.

Expect that the selected text is replaced by the committed text (native VS Code behavior). But actual is: The selected text is kept, and the committed text is inserted before/after the selection.

Single-character commits replace the selection correctly.

Screenshots

https://github.com/user-attachments/assets/fdab694b-81f4-4c45-875a-8572c3aef278

Environment (please complete the following information):

  • VSCodeVim 1.32.4
  • VS Code 1.134
  • Windows 11 24H2

Root cause

In src/textEditor.ts:

https://github.com/VSCodeVim/Vim/blob/8647d427100de3bdf486f4a286cf73759afbebcc/src/textEditor.ts#L26-L41

Path: IME commit → type command (overridden in extensionBase.ts) → handleKeyEvent → TypeInInsertMode → insertTextVSCode transformation → TextEditor.insert().

For text.length === 1, default:type is used and VS Code's native typing semantics replace the selection. For multi-character text, editBuilder.insert() inserts at the end of the selection and never removes the selected range.

The text.length === 1 check exists to avoid VS Code post-typing side effects (auto-closing brackets etc.) on large insertions, but it also drops the selection-replacement semantics of typing.