Bram,
when using Visual-block insert or append, you can't use the cursor keys
to move the cursor to a different location. This will confuse vim.
e.g. consider this block
aaaaaaa
bbbbbbb
ccccccc
Put the Cursor on the first a, and press
l<C-V>jjlllI<Right><Right><Space><Space>
The result will look like this:
aaa aaaa
baabbbbbb
caacccccc
While the result should look like this
aaa aaaa
bbb bbbb
ccc cccc
Attached patch fixes it. It is a little bit fragile, because it depends
on the '[ mark being set correctly, but it seems to work pretty well. If
some plugin messes with this mark in Visual-block mode, it will probably
not be worse then the current situation, so this should be ok.
BTW: I tried to make a new test case for this, but failed, because you
can't use <C-O> in Visual-block Insert/Append mode (this should probably
also be fixed sometimes, this is pretty obvious, since the op_change()
function doesn't care about the return value of the edit() function) and
using the raw terminal keys e.g. <ESC>OC for right are taken literally.
Disclaimer, this problem has first been mentioned at stackoverflow:
http://stackoverflow.com/questions/19030928
regards,
Christian
--
--
--
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/groups/opt_out.
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -2617,6 +2617,29 @@
{
struct block_def bd2;
+ /* Probably the user moved the cursor before inserting something,
+ * so try to adjust the block */
+ if (oap->start.lnum == curbuf->b_op_start.lnum)
+ {
+ if (oap->op_type == OP_INSERT &&
+ oap->start.col != curbuf->b_op_start.col)
+ {
+ oap->start.col = curbuf->b_op_start.col;
+ pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - oap->start_vcol;
+ oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
+ }
+ else if (oap->op_type == OP_APPEND &&
+ oap->end.col >= curbuf->b_op_start.col)
+ {
+ oap->start.col = curbuf->b_op_start.col;
+ /* reset pre_textlen to the value of OP_INSERT */
+ pre_textlen += bd.textlen;
+ pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - oap->start_vcol;
+ oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
+ oap->op_type = OP_INSERT;
+ }
+ }
+
/*
* Spaces and tabs in the indent may have changed to other spaces and
* tabs. Get the starting column again and correct the length.