Keyboard commands like backspace or left/right don't account for Zero Width Joiner (ZWJ) unicode in emoji #9965

Closed
opened 2026-01-31 02:08:37 +00:00 by claunia · 3 comments
Owner

Originally created by @SkylerA on GitHub (Aug 2, 2020).

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0

New Terminal w/ a ubuntu wsl tab opened

Steps to reproduce

  1. Open New Terminal
  2. Open a Ubuntu Tab
  3. Press Win + . to bring up the emoji selector
  4. Select the "Hacker Cat" or any emoji that is a composite of multiple unicode characters
    The hacker cat emoji should now be in the terminal w/ the input cursor behind it
  5. Press left twice
    note that the terminal moved the cursor 2 times even though there is 1 displayed emoji
  6. Press enter
  7. Press up to bring back the hacker cat emoji
  8. Press backspace once
    note that the emoji has changed to just a cat instead of erasing the entire emoji
  9. Press enter
  10. Press up twice to bring back the hacker cat emoji
  11. Press backspace twice
    note that the emoji changes from a hacker cat to a regular cat emoji and finally to a smaller cat emoji w/ the input cursor down the middle of it
    note that pressing backspace or arrow keys will ignore the cat emoji
  12. Hit enter
    note that even though a cat was still in the terminal line, the terminal input command was recorded as blank

Expected behavior

1 character commands like backspace or left/right should treat composite emoji as 1 character

Actual behavior

It appears the terminal is treating each modifier emoji in a composite emoji as an individual character. As far as i understand it, emoji start w/ a base emoji (the cat emoji) and then are modified by adding the ZWJ character and then adding unicode that modifies the previous unicode. My guess is when you do a backspace or left, you need to look and see if the previous character is a unicode ZWJ(there might be other types of modifiers to support in unicode as well, no sure) and if it is, keep parsing until you read a unicode character that isn't proceeded by a ZWJ.

Originally created by @SkylerA on GitHub (Aug 2, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.18362.0 Microsoft Windows NT 10.0.18362.0 New Terminal w/ a ubuntu wsl tab opened ``` # Steps to reproduce 1. Open New Terminal 2. Open a Ubuntu Tab 3. Press Win + . to bring up the emoji selector 4. Select the "Hacker Cat" or any emoji that is a composite of multiple unicode characters _The hacker cat emoji should now be in the terminal w/ the input cursor behind it_ 5. Press left twice _note that the terminal moved the cursor 2 times even though there is 1 displayed emoji_ 6. Press enter 7. Press up to bring back the hacker cat emoji 8. Press backspace once _note that the emoji has changed to just a cat instead of erasing the entire emoji_ 9. Press enter 10. Press up twice to bring back the hacker cat emoji 11. Press backspace twice _note that the emoji changes from a hacker cat to a regular cat emoji and finally to a smaller cat emoji w/ the input cursor down the middle of it_ _note that pressing backspace or arrow keys will ignore the cat emoji_ 12. Hit enter _note that even though a cat was still in the terminal line, the terminal input command was recorded as blank_ # Expected behavior 1 character commands like backspace or left/right should treat composite emoji as 1 character # Actual behavior It appears the terminal is treating each modifier emoji in a composite emoji as an individual character. As far as i understand it, emoji start w/ a base emoji (the cat emoji) and then are modified by adding the [ZWJ](https://emojipedia.org/emoji-zwj-sequence/) character and then adding unicode that modifies the previous unicode. My guess is when you do a backspace or left, you need to look and see if the previous character is a unicode ZWJ(there might be other types of modifiers to support in unicode as well, no sure) and if it is, keep parsing until you read a unicode character that isn't proceeded by a ZWJ.
claunia added the Resolution-Duplicate label 2026-01-31 02:08:37 +00:00
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Aug 3, 2020):

I suspect the backspace behavior is implemented not by Windows Terminal but by the shell (e.g. Bash) you're using in Ubuntu.

@KalleOlaviNiemitalo commented on GitHub (Aug 3, 2020): I suspect the backspace behavior is implemented not by Windows Terminal but by the shell (e.g. Bash) you're using in Ubuntu.
Author
Owner

@zadjii-msft commented on GitHub (Aug 3, 2020):

🐱💻

Yea, the emoji support isn't exactly right quite yet. There's #190 and #1472 which I think should cover this scenario. Someone on the team can overrule me if they want, but I believe this will be fixed when we get to finishing those.

/dup #190
/dup #1472

@zadjii-msft commented on GitHub (Aug 3, 2020): 🐱‍💻 Yea, the emoji support isn't exactly right quite yet. There's #190 and #1472 which I _think_ should cover this scenario. Someone on the team can overrule me if they want, but I _believe_ this will be fixed when we get to finishing those. /dup #190 /dup #1472
Author
Owner

@ghost commented on GitHub (Aug 3, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Aug 3, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9965