-
Notifications
You must be signed in to change notification settings - Fork 34
Description
From Walter Alejandro Iglesias [email protected]
When you yank a word and paste it with 'p' using a numeric prefix, the first character of the string yanked in the last occurrence is pasted at the beginning of the entire string.
In the following example I copied the word "Hello" with the command 'ye' and pasted it on the same line (leaving a space in between to make the example more readable) first using the command '2p' then using '3p':
Hello HHelloHello HHelloHelloHello
In the code, numeral prefixes are handled with a for loop (file vi/v_put.c
). The diff at bottom partially solves the issue, it just removes the following line in the v_put() function:
vp->p_start = vp->m_final;
But, I guess that line must be there for a reason ;-). I said "partially" because even after you remove that line the issue is still reproducible when you paste the word in an empty line. For example:
Hello
HHelloHello
--- vi/v_put.c Thu Apr 24 15:13:56 2025
+++ vi/v_put.c.orig Thu Apr 24 15:13:41 2025
@@ -77,6 +77,7 @@
{
if (F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
vp->p_start, &vp->m_final, 1))
return (1);
+ vp->p_start = vp->m_final;
if (INTERP(vsp))
return (1);
}