On Mi, 18 Sep 2019, Bram Moolenaar wrote:
> I thought we only needed to avoid deleting the following fold and not
> change anything else. But now I read this comment in the help for
> 'whichwrap':
>
> When 'l' is included and it is used after an operator at the end of a
> line then it will not move to the next line. This makes "dl", "cl",
> "yl" etc. work normally.
>
> This would apply since "x" is equivalent to "dl". However, if you try
> "dl" on an empty line, it does delete the line break. It's like the
> cursor is on top of the line break, so that gets deleted.
So how about adjusting the code to do what is actually in the
documentation, so even when the cursor is on the linebreak, do not move
over to the next line. This should also fix the problem that lead to
this patch initially. I think this patch does it:
diff --git a/src/normal.c b/src/normal.c
index f91217ec1..06242b89f 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -5985,8 +5985,7 @@ nv_right(cmdarg_T *cap)
* Set cap->oap->inclusive when last char in the line is
* included, move to next line after that */
if ( cap->oap->op_type != OP_NOP
- && !cap->oap->inclusive
- && !LINEEMPTY(curwin->w_cursor.lnum))
+ && !cap->oap->inclusive)
cap->oap->inclusive = TRUE;
else
{
@@ -7418,13 +7417,7 @@ nv_optrans(cmdarg_T *cap)
{
if (cap->count0)
stuffnumReadbuff(cap->count0);
- // If on an empty line and using 'x' and "l" is included in the
- // whichwrap option, do not delete the next line.
- if (cap->cmdchar == 'x' && vim_strchr(p_ww, 'l') != NULL
- && gchar_cursor() == NUL)
- stuffReadbuff((char_u *)"dd");
- else
- stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
+ stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
}
}
cap->opcount = 0;
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 824a4f22f..d89f91298 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -765,7 +765,7 @@ func Test_fold_delete_with_marker_and_whichwrap()
call setline(1, content1 + content2)
set fdm=marker ww+=l
normal! x
- call assert_equal(content2, getline(1, '$'))
+ call assert_equal(content1 + content2, getline(1, '$'))
set fdm& ww&
bwipe!
endfunc
Best
Christian
--
Das ist das Teuflischste, was eine menschliche Hand tun kann.
Darum zahlen wir mit den schrecklichen Dingen, die in der Welt
geschehen.
-- Mutter Teresa
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20190920100408.GB22701%40256bit.org.