Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Chinese input repeats characters when using VSCodeVim in insert mode

Open SnowDream39 opened this issue 5 months ago • 11 comments
trafficstars

Description

When using Chinese input methods (including Baidu IME, Microsoft Pinyin, etc.) in VS Code with the VSCodeVim extension enabled, all Chinese characters and punctuation are entered twice in insert mode. This issue does not occur when the Vim extension is disabled.

Steps to Reproduce

  1. Enable the VSCodeVim extension
  2. Use any Chinese input method (e.g., Baidu IME, Microsoft Pinyin)
  3. Enter insert mode (i)
  4. Type any Chinese character or punctuation

Expected behavior: Characters should be entered normally, only once
Actual behavior: Each character is entered twice

System Info

  • OS: Windows 11
  • VS Code version: 1.101
  • VSCodeVim version: 1.30.1
  • IME: Baidu IME / Microsoft Pinyin

Additional Notes

This issue persists across different input methods and does not occur in other editors. Disabling the Vim extension fixes the issue.

I've tried:

  • Disabling all other extensions ✔️
  • Reinstalling input methods ✔️
  • Using vim.handleKeys setting (partially helpful) ✔️
  • Enabling Neovim mode (works but requires extra setup) ✔️

Would appreciate any insight or possible fixes. Thank you!

SnowDream39 avatar Jun 13 '25 14:06 SnowDream39

Sure thank u 👍

On Sat, 14 Jun 2025, 12:11 am 星幻丶碎梦, @.***> wrote:

SnowDream39 created an issue (VSCodeVim/Vim#9668) https://github.com/VSCodeVim/Vim/issues/9668 Description

When using Chinese input methods (including Baidu IME, Microsoft Pinyin, etc.) in VS Code with the VSCodeVim extension enabled, all Chinese characters and punctuation are entered twice in insert mode. This issue does not occur when the Vim extension is disabled. Steps to Reproduce

  1. Enable the VSCodeVim extension
  2. Use any Chinese input method (e.g., Baidu IME, Microsoft Pinyin)
  3. Enter insert mode (i)
  4. Type any Chinese character or punctuation

Expected behavior: Characters should be entered normally, only once Actual behavior: Each character is entered twice System Info

  • OS: Windows 11
  • VS Code version: 1.101
  • VSCodeVim version: 1.30.1
  • IME: Baidu IME / Microsoft Pinyin

Additional Notes

This issue persists across different input methods and does not occur in other editors. Disabling the Vim extension fixes the issue.

I've tried:

  • Disabling all other extensions ✔️
  • Reinstalling input methods ✔️
  • Using vim.handleKeys setting (partially helpful) ✔️
  • Enabling Neovim mode (works but requires extra setup) ✔️

Would appreciate any insight or possible fixes. Thank you!

— Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/9668, or unsubscribe https://github.com/notifications/unsubscribe-auth/BS6RJARUOIGPQFYJKE3VHAD3DLLZ5AVCNFSM6AAAAAB7IH2XWSVHI2DSMVQWIX3LMV43ASLTON2WKOZTGE2DGNZSGEZDQOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Adamhub25 avatar Jun 13 '25 14:06 Adamhub25

I have the same problem.

llleixx avatar Jun 13 '25 14:06 llleixx

I have the same problem.

Yukilwc avatar Jun 14 '25 01:06 Yukilwc

Same Problem.

Additional information: When using cursor (which is using VSCode Version 1.96.2 and VSCodeVim version 1.30.1), the problem does not appear. Maybe the bug is caused by the update of VSCode 1.101.

supplient avatar Jun 14 '25 01:06 supplient

I also encountered this problem after updating to v1.101 today. In normal mode, if the input method is Chinese, no matter what you input, it will directly overwrite the characters under the cursor. Also, in insert mode, inputting Chinese punctuation such as commas and full stops will be repeated. Only after disabling the vim plug-in will this problem disappear.

版本: 1.101.0 (user setup) 提交: dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1 日期: 2025-06-11T15:00:50.123Z Electron: 35.5.1 ElectronBuildId: 11727614 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.19045

Ciliphen avatar Jun 14 '25 06:06 Ciliphen

Same issue on Windows after installing the latest VSCode update.

DoLph1nnn avatar Jun 14 '25 08:06 DoLph1nnn

There are also similar issues on Mac, characters may be unexpectedly duplicated or deleted when using Chinese input methods.

For example, in visual mode selecting some characters, pressing 'y' followed by 'esc' with Chinese input method active will paste a segment of characters instead of simply canceling the input.

qiaomo avatar Jun 14 '25 10:06 qiaomo

I have the same problem for version 1.101. no promblem for old version 1.99.3

Bubbl3Bi avatar Jun 15 '25 12:06 Bubbl3Bi

try it, Toggling the setting editor.experimentalEditContextEnabled https://github.com/microsoft/vscode/issues/251518#issuecomment-2973606446

photonCarry avatar Jun 15 '25 13:06 photonCarry

try it, Toggling the setting editor.experimentalEditContextEnabled microsoft/vscode#251518 (comment)

Thank you , It works. I'd like to provide more infomations for someone who still need help.

  1. open the settings
  2. enter editor.experimentalEditContextEnabled
  3. disable it

Image

EuDs63 avatar Jun 16 '25 13:06 EuDs63

~~Hi VS Code developer here. This is a VS Code bug with a fix here: https://github.com/microsoft/vscode/pull/251826 which should make VIM work correctly when the setting editor.experimentalEditContextEnabled (soon to be editor.editContext) is turned on. Generally the editor.experimentalEditContextEnabled setting fixes certain IME bugs like the jittering of the text on input. Hopefully after the VIM issue is fixed, the setting can improve your IME experience within VS Code.~~

~~To the VIM authors, this PR essentially always calls the CompositionType handler during composition when using the EditContext API. Since the VIM extension does not override the CompositionType handler, that means that users will be able to do IME composition in the normal mode in Chinese and use English for the VIM commands. Hopefully this makes for a better IME experience as users will not need to change to insert mode to input Chinese.~~

aiday-mar avatar Jun 18 '25 16:06 aiday-mar

Hopefully this makes for a better IME experience as users will not need to change to insert mode to input Chinese.

No, it's actually desirable to switch to insert mode in order to input Chinese.

llleixx avatar Jun 19 '25 11:06 llleixx

Hi everyone, I have looked again at the issue and I noticed the following. When the EditContext is enabled and the Chinese Microsoft Pinyin IME is used, after typing a dot, we receive a textupdate event. We reset the EditContext state and this makes the Microsoft Pinyin IME send a second textupdate event, which is the reason a second dot is added. Generally you can see this happen on the following HTML example:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <div id="html-editor" spellcheck="false" style="border:1px solid black"></div>

    <script>
        const IS_EDIT_CONTEXT_SUPPORTED = 'EditContext' in window;
        console.log('IS_EDIT_CONTEXT_SUPPORTED : ', IS_EDIT_CONTEXT_SUPPORTED);

        const editorEl = document.getElementById("html-editor");
        editorEl.style.height = '200px';
        editorEl.style.width = '100%';

        if (IS_EDIT_CONTEXT_SUPPORTED) {
            const editContext = new EditContext();
            editorEl.editContext = editContext;

            editContext.addEventListener("textupdate", e => {
                console.log('textupdate : ', e);
                editContext.text = '';
                editContext.selectionStart = 0;
                editContext.selectionEnd = 0;

            });
        }
    </script>
</body>
</html>

If you type . while using the IME, it fires two text-update events. This looks like it could be a bug with the IME. I will discuss this with the team.

https://github.com/user-attachments/assets/8fe4415c-06e6-4184-9607-feaae9864826

aiday-mar avatar Jun 19 '25 16:06 aiday-mar

try it, Toggling the setting editor.experimentalEditContextEnabled microsoft/vscode#251518 (comment)

Thank you , It works. I'd like to provide more infomations for someone who still need help.

  1. open the settings
  2. enter editor.experimentalEditContextEnabled
  3. disable it

Image

It works.

aiyolo avatar Jun 20 '25 04:06 aiyolo

see Edit Context

open setings editor.experimentalEditContextEnabled

or editor setings.json editor.experimentalEditContextEnabled to false fix this

{
	"editor.experimentalEditContextEnabled": false
}

pass test at

  • VSCode version: 1.101.2
  • Extension (VsCodeVim) version: 1.30.1
OS: Microsoft Windows 11
10.0.26100
10.0.22621

sinlov avatar Jun 27 '25 10:06 sinlov

I have recently pushed a fix which should fix this even when the setting is enabled. Should work on insiders now.

aiday-mar avatar Jun 30 '25 11:06 aiday-mar

Seems like it’s been fixed in VSCode 1.102.0.

llleixx avatar Jul 12 '25 05:07 llleixx

Seems like it’s been fixed in VSCode 1.102.0.

No, vscode 1.102.1 on osx still have this problem.

wvq avatar Jul 18 '25 12:07 wvq

Hi @wvq thanks for letting me know. Could you file an issue showing how to reproduce this issue on the VS Code repo with a screen recording?

aiday-mar avatar Jul 18 '25 13:07 aiday-mar

Hi @aiday-mar, In my case only the first input character is repeated once, and the repeated character is executed as vim command.

vscode 1.102.1 vscodevim.vim 1.30.1

https://github.com/user-attachments/assets/ad13d0b9-f66e-4bda-813d-7a623cb15f04

I'm using chinese Wubi IME, input vkjs = 如果,

expect is test 如果input, acture is test v如果nput, first letter v is executed as vim command.

wvq avatar Jul 18 '25 19:07 wvq

expect is test 如果input, acture is test v如果nput, first letter v is executed as vim command.

No, the letter v was simply inserted into the text, and the letter i was replaced when you typed the second k. This behavior is quite strange.

Also, this bug seems to occur only when typing Chinese characters immediately after entering insert mode in VIM.

llleixx avatar Jul 19 '25 03:07 llleixx

@llleixx you are right. After more testing, switch to insert mode by i has this bug, other commands is OK, like a or o.

If I change the cursor to other position and set it back, everything is OK.

@RegisterAction
export class CommandInsertAtCursor extends BaseCommand {
  modes = [Mode.Normal];
  keys = [['i'], ['<Insert>']];

  public override async exec(position: Position, vimState: VimState): Promise<void> {
    await vimState.setCurrentMode(Mode.Insert);

    // test code:
    const editor = vscode.window.activeTextEditor

    if(editor) {
      // set cursor to somewhere else
      editor.selection = new vscode.Selection(position.getLeft(), position.getLeft())

      setTimeout(() => {
        // set cursor back
        editor.selection = new vscode.Selection(position, position)
      }, 0)
    }
    
    // end test code
  }

  // ...
}

But I can't find any difference of activeTextEditor state.

wvq avatar Jul 20 '25 06:07 wvq

Hi wvq thanks for the comment. Could you file the issue here: https://github.com/microsoft/vscode/issues

aiday-mar avatar Jul 21 '25 07:07 aiday-mar

@aiday-mar I don't understand. This doesn't seem like a VSCode's bug.

wvq avatar Jul 30 '25 09:07 wvq

@aiday-mar I don't understand. This doesn't seem like a VSCode's bug.

我也遇到相同问题了, 你解决了嘛哥。 苦恼死我了这个问题。

puck1006 avatar Aug 05 '25 05:08 puck1006

@aiday-mar I don't understand. This doesn't seem like a VSCode's bug.

解决了

Image 把这个勾选去掉!!!!

puck1006 avatar Aug 05 '25 06:08 puck1006

@puck1006 -_- 这个issue本来就有解决方案了嘛,只是没处理掉这个bug

wvq avatar Aug 09 '25 17:08 wvq

@aiday-mar https://github.com/microsoft/vscode/issues/261797 Tracked here.

wenfangdu avatar Aug 15 '25 11:08 wenfangdu

Fixed by https://github.com/microsoft/vscode/issues/261797.

wenfangdu avatar Sep 05 '25 04:09 wenfangdu

I am in vscode version v1.104, the editor.experimentalEditContextEnabled has became editor.EditContext.
I enabled it and found not issue now.
See if this issue can be closed. If so, I can link all the same issue this the solution and close all of them.

yodalee avatar Oct 04 '25 23:10 yodalee