Skip to content

Commit

Permalink
Fix regression in deleteCharBackward
Browse files Browse the repository at this point in the history
FIX: Fix a regression that caused `deleteCharBackward` to sometimes
delete a large chunk of text.

See https://discuss.codemirror.net/t/backspace-on-some-multi-codepoint-glyphs-deletes-characters-separately/7403
  • Loading branch information
marijnh committed Nov 28, 2023
1 parent de16f6b commit 27970fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ const deleteByChar = (target: CommandTarget, forward: boolean) => deleteBy(targe
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)
targetPos = findClusterBreak(line.text, targetPos - line.from, false, false) + line.from
}
return targetPos
})
Expand Down

0 comments on commit 27970fd

Please sign in to comment.