From fd8055b2fa3ac42eec5095fb4547410c246fbb90 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Sat, 11 Nov 2023 15:22:27 +0100 Subject: [PATCH] Skip variant selectors in deleteCharBackward FIX: `deleteCharBackward` will no longer delete variant selector characters as separate characters. See https://discuss.codemirror.net/t/backspace-on-some-multi-codepoint-glyphs-deletes-characters-separately/7403 --- src/commands.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands.ts b/src/commands.ts index 8a0d3c4..cdc33d9 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -478,6 +478,8 @@ const deleteByChar = (target: CommandTarget, forward: boolean) => deleteBy(targe targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from if (targetPos == pos && line.number != (forward ? state.doc.lines : 1)) targetPos += forward ? 1 : -1 + else if (!forward && /[\ufe00-\ufe0f]/.test(line.text.slice(targetPos - line.from, pos - line.from))) + targetPos = findClusterBreak(line.text, targetPos - line.from, false, false) } return targetPos })