vim-patch:8.2.3820: "vrc" does not replace composing characters

Problem:    "vrc" does not replace composing characters, while "rc" does.
Solution:   Check the byte length including composing characters.
            (closes vim/vim#9351)
8ee6028de3

vim-patch:8.2.3823: test for visual replace is in wrong function

Problem:    Test for visual replace is in wrong function.
Solution:   Move it to another function.
6ecf58b0d7
This commit is contained in:
zeertzjq
2022-02-15 09:35:43 +08:00
parent 1bd6c0a05c
commit 8f3e56ed3a
2 changed files with 10 additions and 2 deletions

View File

@@ -1961,11 +1961,14 @@ static int op_replace(oparg_T *oap, int c)
while (ltoreq(curwin->w_cursor, oap->end)) {
n = gchar_cursor();
if (n != NUL) {
if (utf_char2len(c) > 1 || utf_char2len(n) > 1) {
int new_byte_len = utf_char2len(c);
int old_byte_len = utfc_ptr2len(get_cursor_pos_ptr());
if (new_byte_len > 1 || old_byte_len > 1) {
// This is slow, but it handles replacing a single-byte
// with a multi-byte and the other way around.
if (curwin->w_cursor.lnum == oap->end.lnum) {
oap->end.col += utf_char2len(c) - utf_char2len(n);
oap->end.col += new_byte_len - old_byte_len;
}
replace_character(c);
} else {