diff src/register.c @ 34096:429644dfc975 v9.1.0015

patch 9.1.0015: i_CTRL-R- no longer works in replace mode Commit: https://github.com/vim/vim/commit/5d5cbb2b9ac526fb6fad2116e24a282affc45efe Author: Christian Brabandt <cb@256bit.org> Date: Fri Jan 5 18:19:52 2024 +0100 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: #13792 closes: #13816 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Jan 2024 18:30:04 +0100
parents 82e8284e60b7
children 099e0a527665
line wrap: on
line diff
--- a/src/register.c
+++ b/src/register.c
@@ -828,9 +828,22 @@ insert_reg(
 	    {
 		if (regname == '-')
 		{
+		    int dir = BACKWARD;
+		    if ((State & REPLACE_FLAG) != 0)
+		    {
+			pos_T curpos;
+			u_save_cursor();
+			del_bytes((long)STRLEN(y_current->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, 1L, PUT_CURSEND);
+		    do_put(regname, NULL, dir, 1L, PUT_CURSEND);
 		}
 		else
 		    stuffescaped(y_current->y_array[i], literally);