edit icon indicating copy to clipboard operation
edit copied to clipboard

Emoji breaks cursor position and blocks backspace

Open o-sdn-o opened this issue 3 months ago โ€ข 9 comments

In WSL, pasting the 'family' emoji via the Emoji Picker (Win+'.') misplaces the cursor position and blocks backspace.

Repro:

  1. Run WSL profile in Windows Terminal
  2. Run edit
  3. Press Win+'.' for Emoji Picker
  4. Paste the 'family: man, woman, girl, boy' emoji and press Esc
  5. 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

o-sdn-o avatar Sep 24 '25 13:09 o-sdn-o

You've changed this setting, right?

Image

lhecker avatar Sep 24 '25 13:09 lhecker

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

o-sdn-o avatar Sep 24 '25 14:09 o-sdn-o

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).

o-sdn-o avatar Sep 24 '25 14:09 o-sdn-o

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.

o-sdn-o avatar Sep 24 '25 18:09 o-sdn-o

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.

DHowett avatar Sep 24 '25 19:09 DHowett

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.

o-sdn-o avatar Sep 24 '25 20:09 o-sdn-o

Image

o-sdn-o avatar Sep 24 '25 20:09 o-sdn-o

For repro, it is enough to paste the first part of the grapheme cluster twice using the clipboard.

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€

o-sdn-o avatar Sep 24 '25 21:09 o-sdn-o

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.

o-sdn-o avatar Sep 25 '25 07:09 o-sdn-o