Emoji breaks cursor position and blocks backspace
In WSL, pasting the 'family' emoji via the Emoji Picker (Win+'.') misplaces the cursor position and blocks backspace.
Repro:
- Run WSL profile in Windows Terminal
- Run
edit - Press Win+'.' for Emoji Picker
- Paste the 'family: man, woman, girl, boy' emoji and press Esc
- Check the cursor position and whether the backspace is working
Tested on Win11 and Win10.
https://github.com/user-attachments/assets/cbd3ffb7-c493-41c1-b431-4bae70685d53
You've changed this setting, right?
This behavior occurs despite the fact that 'Grapheme clusters' is set in the settings.
https://github.com/user-attachments/assets/f747610d-646c-46e4-ad7d-9fa9485bcf85
This only happens under WSL. Only with the native Linux binary, only when using the Emoji Picker (Win+'.').
Additional observations:
- The emoji picker doesn't work for edit.exe (win32 binary) running under WSL.
- When pasting these emoji '๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ' from the clipboard, everything works as expected (no issues).
- With word wrap enabled (Alt+Z), everything works as expected (no issues).
- Resizing window or pressing 'Home' then 'End' restores backspace functionality and cursor position.
- This behavior does not occur when using
vtm -r wsl->edit(possibly due to the different TSF/IME backing in vtm and WT). - This behavior occurs when using
WT->vtm --tui -r wsl->edit. - When using conhost (
conhost->wsl->edit), backspace also stops working after picking such emoji (not to mention that it doesn't support grapheme clusters). - Tested with latest WT (built from current main, x64).
Repro on post-quantum hardware (my iron is quite slow, allowing me to catch issues related to timeouts):
- Split the grapheme cluster
๐จโ๐ฉโ๐งโ๐ฆinto two parts:
and๐จโ๐ฉโ๐งโ๐ฉ - Paste the first and then the second using the clipboard.
I do not believe that repro to be representative of what is actually happening.
Edit requests bracketed paste mode, and so on any conforming terminal emulator your instructions will result in \e[201~\e[200~ being inserted after the last ZWJ in the first segment and before the first code unit in the second segment.
Yes, this isn't the same behavior; at least the result (text) looks different visually, but after pasting both parts, backspace also stops working, and the cursor position is broken, just like in the original issue.
I don't know if this issue is reproducible on faster hardware. The code point stream from the terminal is the same whether using vtm or WT (showkey -a shows this), but with a certain actor configuration (TSF+WT+WSL+edit), the issue persists.
For repro, it is enough to paste the first part of the grapheme cluster twice using the clipboard.
๐จโ๐ฉโ๐งโ
Edit requests bracketed paste mode, and so on any conforming terminal emulator your instructions will result in \e[201~\e[200~ being inserted after the last ZWJ in the first segment and before the first code unit in the second segment.
Edit successfully receives inserted blocks wrapped in a bracketed paste sequence and there are no issues with this. When receiving a grapheme cluster in parts, it does something wrong.