Backspace on some multi-codepoint glyphs deletes characters separately

Left and right arrow keys move around multi-codepoint glyphs, such as :arrow_left: and :running_woman:t2:, atomically. Forward delete similarly works on the glyphs atomically.

However, pressing backspace after these multi-codepoint glyphs seems to delete the characters separately. Is the latter behavior controlled by CM itself, and if so, is it intended?

EDIT: Apparently copy and paste from Discourse pastes the emoji short code. The arrow can be copied from Emojipedia arrows. The runner glyph can be copied from the last table in Zero-width joiner - Wikipedia.

This is intentional behavior and matches how many editors (for example Firefox’s native edit controls and VS Code) behave.

The arrow seems to backspace as one character in Firefox HTML controls and VS Code instead two in CM, while the runner emoji backspaces as two characters in Firefox and VS Code instead of three characters in CM, but I see your point and I could imagine the behavior in Firefox and VS Code being hard to replicate. Thanks for your response!

Oh, that’s a good point. This patch makes it so that variant selectors are deleted together with the character they are attached to.

1 Like

Thanks for the patch! Did the patch introduce a weird deletion bug though? When the multi-codepoint emoji is on its own line after another block of text or after some code, backspace behind the emoji seems to delete a seemingly random selection in the web demo now. When the emoji is after some plain text, the behavior seems to be correct. Please see the recording below.

Backspace Bug

Yeah, that was a regression. This patch should help.

1 Like