From 2783b6b0a48389f5e12109d9894269768c3e9fe5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Jan 2024 07:01:08 +0800 Subject: vim-patch:9.1.0015: i_CTRL-R- no longer works in replace mode Problem: i_CTRL-R- no longer works in replace mode Solution: delete characters in replace mode before putting, add a test, add a bit warning into the documentation, that i_CTRL-R-P/O is not supported in Replace mode for now fixes: vim/vim#13792 closes: vim/vim#13816 https://github.com/vim/vim/commit/5d5cbb2b9ac526fb6fad2116e24a282affc45efe Co-authored-by: Christian Brabandt --- src/nvim/ops.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/nvim') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 8386dcaec6..32095177be 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1282,9 +1282,22 @@ int insert_reg(int regname, bool literally_arg) } else { for (size_t i = 0; i < reg->y_size; i++) { if (regname == '-') { + Direction dir = BACKWARD; + if ((State & REPLACE_FLAG) != 0) { + pos_T curpos; + u_save_cursor(); + del_bytes((colnr_T)strlen(reg->y_array[0]), true, false); + curpos = curwin->w_cursor; + if (oneright() == FAIL) { + // hit end of line, need to put forward (after the current position) + dir = FORWARD; + } + curwin->w_cursor = curpos; + } + AppendCharToRedobuff(Ctrl_R); AppendCharToRedobuff(regname); - do_put(regname, NULL, BACKWARD, 1, PUT_CURSEND); + do_put(regname, NULL, dir, 1, PUT_CURSEND); } else { stuffescaped(reg->y_array[i], literally); } -- cgit From 64a50d08c4866011be73d6af0e8ae90e06c3f949 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Jan 2024 08:29:54 +0800 Subject: vim-patch:9.1.0021: i_CTRL-R- doesn't work for multibyte chars in Replace mode Problem: i_CTRL-R- doesn't work for multibyte chars in Replace mode, Coverity complains missing return value for u_save_cursor() Solution: Use mb_charlen() and del_chars() instead, handle failure mode for u_save_cursor() correctly (@zeertzjq) closes: vim/vim#13846 https://github.com/vim/vim/commit/424ec1f235a53131042aed94d30f6e2528e551d9 --- src/nvim/ops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 32095177be..84cba5d05c 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1286,7 +1286,10 @@ int insert_reg(int regname, bool literally_arg) if ((State & REPLACE_FLAG) != 0) { pos_T curpos; u_save_cursor(); - del_bytes((colnr_T)strlen(reg->y_array[0]), true, false); + if (u_save_cursor() == FAIL) { + return FAIL; + } + del_chars(mb_charlen(reg->y_array[0]), true); curpos = curwin->w_cursor; if (oneright() == FAIL) { // hit end of line, need to put forward (after the current position) -- cgit