Christian Brabandt wrote:
> this example throws ml_get errors:
> ,----
> | set bs=2
> | exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\<C-D>uvwxyz"
> | call cursor(1,1)
> | exe "normal gR0\<del> 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR"
> `----
>
> Problem is, that once a linebreak is deleted in virtual replace mode,
> orig_lines_count is not correctly reset.
>
> Here is a patch that fixes that issue and includes a test.
>
> diff --git a/src/edit.c b/src/edit.c
> index 47227d34b..10bfd08a1 100644
> --- a/src/edit.c
> +++ b/src/edit.c
> @@ -8927,7 +8927,17 @@ ins_del(void)
> || do_join(2, FALSE, TRUE, FALSE, FALSE) == FAIL)
> vim_beep(BO_BS);
> else
> + {
> curwin->w_cursor.col = temp;
> +#ifdef FEAT_VREPLACE
> + if (State & VREPLACE_FLAG)
> + {
> + orig_line_count = curbuf->b_ml.ml_line_count;
> + if (vr_lines_changed > 1)
> + vr_lines_changed--;
> + }
> +#endif
Hmm, I suspect this needs a check whether the cursor is in the first
changed line or not. Compare with the do_join() in ins_bs(), it doesn't
adjust vr_lines_changed or orig_line_count there.
> + }
> }
> else if (del_char(FALSE) == FAIL) /* delete char under cursor */
> vim_beep(BO_BS);
> diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
> index 4287a9e49..d7e9bc7e5 100644
> --- a/src/testdir/test_visual.vim
> +++ b/src/testdir/test_visual.vim
> @@ -186,4 +186,22 @@ func Test_virtual_replace()
> call assert_equal(['AB......CDEFGHI.Jkl',
> \ 'AB IJKLMNO QRst'], getline(12, 13))
> enew!
> + set noai bs&vim t_kD&vim t_kb&vim
> +endfunc
> +
> +" Test Virtual replace mode.
> +func Test_virtual_replace2()
> + enew!
> + exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\<C-D>uvwxyz"
> + call cursor(1,1)
> + set bs=2
> + exe "normal gR0\<del> 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR"
> + call assert_equal(['0 1',
> + \ 'A',
> + \ 'BCDEFGHIJ',
> + \ ' KL',
> + \ 'MNO',
> + \ 'PQR',
> + \ ], getline(1, 6))
> + set bs&vim
> endfunc
>
> However I am not sure, vr_lines_changed should be decremented.
It is used to decide whether or not to save the next line for undo.
this is in open_line(). Perhaps you can make a test case that enters NL
in virtual replace mode, then DEL to join the next line, then enters NL
again, check if undo still works as expected.
--
Windows
M!uqoms
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.