summaryrefslogtreecommitdiffstats
path: root/src/mbyte.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-26 20:38:36 +0100
committerChristian Brabandt <cb@256bit.org>2024-02-26 20:38:36 +0100
commitff2b79d23956263ab0120623c37e0b4498be01db (patch)
tree9f7360e2130555bea3602a4b59348aee4c651043 /src/mbyte.c
parentdb7622ea827034124c22da0c235ff5170e44b8bc (diff)
patch 9.1.0137: <Del> in cmdline mode doesn't delete composing charsv9.1.0137
Problem: <Del> in cmdline mode doesn't delete composing chars Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq) closes: #14095 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index 0427f0ce3c..d6d81c4c71 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -4188,32 +4188,12 @@ mb_copy_char(char_u **fp, char_u **tp)
int
mb_off_next(char_u *base, char_u *p)
{
- int i;
- int j;
+ int head_off = (*mb_head_off)(base, p);
- if (enc_utf8)
- {
- if (*p < 0x80) // be quick for ASCII
- return 0;
-
- // Find the next character that isn't 10xx.xxxx
- for (i = 0; (p[i] & 0xc0) == 0x80; ++i)
- ;
- if (i > 0)
- {
- // Check for illegal sequence.
- for (j = 0; p - j > base; ++j)
- if ((p[-j] & 0xc0) != 0x80)
- break;
- if (utf8len_tab[p[-j]] != i + j)
- return 0;
- }
- return i;
- }
+ if (head_off == 0)
+ return 0;
- // Only need to check if we're on a trail byte, it doesn't matter if we
- // want the offset to the next or current character.
- return (*mb_head_off)(base, p);
+ return (*mb_ptr2len)(p - head_off) - head_off;
}
/*