diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-27 06:09:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 06:09:06 +0800 |
commit | 0d75324e3b7e9ab1ade4f11ee10f20840b1dd6dd (patch) | |
tree | dc3eaff204513ec67937a5d0c3111bdf3fc943ac /src/nvim/mbyte.c | |
parent | 2ce3a9efa7ccfed359dc2bfb2e81177034977d40 (diff) | |
download | rneovim-0d75324e3b7e9ab1ade4f11ee10f20840b1dd6dd.tar.gz rneovim-0d75324e3b7e9ab1ade4f11ee10f20840b1dd6dd.tar.bz2 rneovim-0d75324e3b7e9ab1ade4f11ee10f20840b1dd6dd.zip |
vim-patch:9.1.0137: <Del> in cmdline mode doesn't delete composing chars (#27636)
Problem: <Del> in cmdline mode doesn't delete composing chars
Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq)
closes: vim/vim#14095
https://github.com/vim/vim/commit/ff2b79d23956263ab0120623c37e0b4498be01db
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index cf206aa68b..c7a56209e4 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1884,6 +1884,20 @@ void mb_copy_char(const char **const fp, char **const tp) *fp += l; } +/// Return the offset from "p" to the first byte of a character. When "p" is +/// at the start of a character 0 is returned, otherwise the offset to the next +/// character. Can start anywhere in a stream of bytes. +int mb_off_next(const char *base, const char *p) +{ + int head_off = utf_head_off(base, p); + + if (head_off == 0) { + return 0; + } + + return utfc_ptr2len(p - head_off) - head_off; +} + /// Returns the offset in bytes from "p_in" to the first and one-past-end bytes /// of the codepoint it points to. /// "p_in" can point anywhere in a stream of bytes. |