fix(grid): don't use utfc_ptr2char_len() when printing until NUL

This commit is contained in:
zeertzjq
2022-07-22 06:55:35 +08:00
committed by GitHub
parent 68d2bb4070
commit 567bb36edf

View File

@@ -5853,16 +5853,12 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col
&& *ptr != NUL) {
c = *ptr;
// check if this is the first byte of a multibyte
if (len > 0) {
mbyte_blen = utfc_ptr2len_len(ptr, (int)((text + len) - ptr));
} else {
mbyte_blen = utfc_ptr2len(ptr);
}
if (len >= 0) {
u8c = utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr));
} else {
u8c = utfc_ptr2char(ptr, u8cc);
}
mbyte_blen = len > 0
? utfc_ptr2len_len(ptr, (int)((text + len) - ptr))
: utfc_ptr2len(ptr);
u8c = len >= 0
? utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr))
: utfc_ptr2char(ptr, u8cc);
mbyte_cells = utf_char2cells(u8c);
if (p_arshape && !p_tbidi && arabic_char(u8c)) {
// Do Arabic shaping.
@@ -5871,8 +5867,9 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col
nc = NUL;
nc1 = NUL;
} else {
nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc,
(int)((text + len) - ptr - mbyte_blen));
nc = len >= 0
? utfc_ptr2char_len(ptr + mbyte_blen, pcc, (int)((text + len) - ptr - mbyte_blen))
: utfc_ptr2char(ptr + mbyte_blen, pcc);
nc1 = pcc[0];
}
pc = prev_c;