mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 05:48:17 +00:00
feat(mbyte): support extended grapheme clusters including more emoji
Use the grapheme break algorithm from utf8proc to support grapheme clusters from recent unicode versions. Handle variant selector VS16 turning some codepoints into double-width emoji. This means we need to use ptr2cells rather than char2cells when possible.
This commit is contained in:
@@ -896,14 +896,15 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
|
||||
// delete the last combining character.
|
||||
if (p_deco && use_delcombine && utfc_ptr2len(oldp + col) >= count) {
|
||||
char *p0 = oldp + col;
|
||||
if (utf_composinglike(p0, p0 + utf_ptr2len(p0))) {
|
||||
GraphemeState state = GRAPHEME_STATE_INIT;
|
||||
if (utf_composinglike(p0, p0 + utf_ptr2len(p0), &state)) {
|
||||
// Find the last composing char, there can be several.
|
||||
int n = col;
|
||||
do {
|
||||
col = n;
|
||||
count = utf_ptr2len(oldp + n);
|
||||
n += count;
|
||||
} while (utf_composinglike(oldp + col, oldp + n));
|
||||
} while (utf_composinglike(oldp + col, oldp + n, &state));
|
||||
fixpos = false;
|
||||
}
|
||||
}
|
||||
@@ -1694,7 +1695,7 @@ bool open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
||||
}
|
||||
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) {
|
||||
while ((*p_extra == ' ' || *p_extra == '\t')
|
||||
&& !utf_iscomposing(utf_ptr2char(p_extra + 1))) {
|
||||
&& !utf_iscomposing_first(utf_ptr2char(p_extra + 1))) {
|
||||
if (REPLACE_NORMAL(State)) {
|
||||
replace_push(*p_extra);
|
||||
}
|
||||
|
Reference in New Issue
Block a user