aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mbyte.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-09-29 10:05:27 +0200
committerbfredl <bjorn.linse@gmail.com>2024-11-04 13:12:33 +0100
commit23290e7676e6f0a5cb5d9dc9fa1933df815aed33 (patch)
treee712c30a591bd0a142e1411f76bb568a49e97057 /src/nvim/mbyte.c
parent0da4d89558a05fb86186253e778510cfd859caea (diff)
downloadrneovim-23290e7676e6f0a5cb5d9dc9fa1933df815aed33.tar.gz
rneovim-23290e7676e6f0a5cb5d9dc9fa1933df815aed33.tar.bz2
rneovim-23290e7676e6f0a5cb5d9dc9fa1933df815aed33.zip
feat(editor): handle new multibyte sequences in normal mode replacement
while the implementation is not tied to screen chars, it is a reasonable expectation to support the same size. If nvim is able to display a multibyte character, it will accept the same character as input, including in normal mode commands like r{char}
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r--src/nvim/mbyte.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 6340ff8c94..65f718f925 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -839,6 +839,13 @@ bool utf_composinglike(const char *p1, const char *p2, GraphemeState *state)
return arabic_combine(first, second);
}
+/// same as utf_composinglike but operating on UCS-4 values
+bool utf_iscomposing(int c1, int c2, GraphemeState *state)
+{
+ return (!utf8proc_grapheme_break_stateful(c1, c2, state)
+ || arabic_combine(c1, c2));
+}
+
/// Get the screen char at the beginning of a string
///
/// Caller is expected to check for things like unprintable chars etc
@@ -1852,8 +1859,7 @@ StrCharInfo utfc_next_impl(StrCharInfo cur)
while (true) {
uint8_t const next_len = utf8len_tab[*next];
int32_t const next_code = utf_ptr2CharInfo_impl(next, (uintptr_t)next_len);
- if (utf8proc_grapheme_break_stateful(prev_code, next_code, &state)
- && !arabic_combine(prev_code, next_code)) {
+ if (!utf_iscomposing(prev_code, next_code, &state)) {
return (StrCharInfo){
.ptr = (char *)next,
.chr = (CharInfo){ .value = next_code, .len = (next_code < 0 ? 1 : next_len) },