Chinese IME input inside string literals causes garbled pinyin characters to appear in SQL editor

Description When typing Chinese inside a single-quoted SQL string, intermediate pinyin text may remain after confirming the Chinese candidate. Existing text can also disappear or be replaced unexpectedly.

Steps to reproduce

  1. Open an editor with SQL syntax highlighting enabled.
  2. Type a single quote '.
  3. Switch to a Chinese Pinyin IME.
  4. Type zcfzb and select 资产负债表.
  5. Repeat if necessary—the issue is intermittent. Expected behavior Confirming the candidate replaces the intermediate pinyin with 资产负债表, preserving the surrounding text. Actual behavior Intermediate characters remain alongside the Chinese text, for example: 'z'c'f'z'b资产负债表' Sometimes surrounding text disappears or is replaced.

Additional observations

  • Reported with @codemirror/view 6.43.0.
  • Reproduces intermittently on Windows.
  • Ordinary typing did not reproduce it on macOS, where the IME displayed spaces between letters rather than apostrophes.
  • Not observed when SQL language support is disabled.

Original issue

Which browser are you seeing this in?

Hi! We’ve been testing with Chrome

I tried reproducing this (Chrome 153 Windows, Simplified Chinese Pinyin keyboard). I create an editor with just [basicSetup(), sql()] as extensions, and two single quotes as initial content. Then I put the cursor between the quotes and repeatedly type z-c-f-z-b-Space. But I’m getting only the Chinese text—the Latin characters disappear as they are supposed to. Am I doing something different from how you reproduce this?

like this: select ‘123123213131’,‘sdfsfsd’,t.* from DIM_AREA t where t.city=‘北京’;

If you want to replace ‘北京’ with ‘上海’, then the whole SQL will turn into a meaningless statement.

I was able to reproduce this in both Chrome and Edge.

You need to connect to a database first, like SQLite or some other database, and then open the SQL editor. If you type Chinese in the quotes, the characters will get replaced.

If the issue requires a database to reproduce, it is likely not a CodeMirror problem. If you can set up an editor in codemirror.net/try that reproduces it, do let me know.