Okay, I really need to get some coffee.
Resending to vim-dev, because attachments obviously do not make it to github.
On Di, 10 Nov 2015, Dimitar Dimitrov wrote:
> Steps to reproduce:
>
> Create a file with contents:
> ```
> 1 lorem
> 2 bla
> ```
>
> Now, `:set ve=all`
>
> Go in virtual column 7 on the first line and start visual block mode with
> `^v`, then `j`
>
> Now when trying `I@`, we get:
> ```
> 1 lorem @
> 2 bla
> ```
>
> instead of:
> ```
> 1 lorem @
> 2 bla @
> ```
>
> Note `A@` does what we want
>
> Tested with `Vim 7.4`, `1-884` (`vim -nNX -u NONE`)
block editing is a little bit tricky, but I think the attached patch
fixes it. Please check (includes a test to verify)
Best,
Christian
--
Werbung ist die Mystik des 21. Jahrhundert.
-- Thomas Niederreuther
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -569,6 +569,7 @@ block_insert(oap, s, b_insert, bdp)
char_u *newp, *oldp; /* new, old lines */
linenr_T lnum; /* loop var */
int oldstate = State;
+ int extra = 0; /* prepend spaces before s */
State = INSERT; /* don't want REPLACE for State */
s_len = (unsigned)STRLEN(s);
@@ -577,12 +578,30 @@ block_insert(oap, s, b_insert, bdp)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
- continue; /* OP_INSERT, line ends before block start */
+ {
+#ifdef FEAT_VIRTUALEDIT
+ if (ve_flags == VE_ALL)
+ {
+ char_u *p = ml_get(lnum);
+ int len = 0;
+ extra = oap->start.coladd;
+ len = linetabsize(p);
+ if (len > oap->start.col)
+ extra -= (len - oap->start.col);
+ else
+ extra += (oap->start.col - len);
+ }
+
+ else
+#endif
+ continue; /* OP_INSERT, line ends before block start */
+ }
oldp = ml_get(lnum);
if (b_insert)
{
+ count = 0;
p_ts = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
@@ -629,6 +648,9 @@ block_insert(oap, s, b_insert, bdp)
}
#endif
+ spaces += extra;
+ count += extra;
+
newp = alloc_check((unsigned)(STRLEN(oldp)) + s_len + count + 1);
if (newp == NULL)
continue;
diff --git a/src/testdir/test39.in b/src/testdir/test39.in
--- a/src/testdir/test39.in
+++ b/src/testdir/test39.in
@@ -80,6 +80,16 @@ G3o987652k02l2jr
:4,7y
Gp
:exe ":norm! f0\<C-V>2jI\<tab>\<esc>"
+:"
+:" block_insert in virtualedit mode and prepending spaces
+:$put =''
+:$put ='tw'
+:$put ='ä'
+:$put ='two'
+:$put ='three'
+:$put ='ä'
+:set ve=all
+04k7l4jIXXX
:/^the/,$w >> test.out
:qa!
ENDTEST
diff --git a/src/testdir/test39.ok b/src/testdir/test39.ok
index 349d67fe775b797974d039d14e918edecdee245f..c853901bd77c198b917786956746e04957f56134
GIT binary patch
literal 718
zc$|e&+iJo<5bbLQ`VRwr7Lwg~r4)=2EJy<;f%K_lla1O&(-y_ppY2OO#K~6EHMMjf
z&di*1X7<9y<^Dq?sm$h!<?~Cvf|!UmT8Ow>7Y3@;6lGS4h<~YbQWZm^E9R)jF(Ls7
zArJ{5NfJZ?NYfON0O0oZuB<#1MP;FwR1S)%G7K4y1=#IQmjXD9qgIYiVl27<$McnF
z<jb|R8Z~RwTx&RCqfe*VWtygJ77`!5FbI8r9EK>@DYS6!QK_hCi!BHyW8E`;aKW;y
z3#>C8PSCvv*P{>yz!<CM?~5}R=e+Lyl-sS^)MDIjL$}wznDu+to%R|2=f6_UA54mT
zU}KSG0~6qe{t#Us9q(y4of?K&nx<*#wBxJa^sO*m8O{8errGp_JN2kh6u}qP>1J2d
K>Ed0=Uxou9X}C`S