Skip to content

Commit 7a9bd7c

Browse files
committed
patch 8.1.2052: using "x" before a closed fold may delete that fold
Problem: Using "x" before a closed fold may delete that fold. Solution: Do not translate 'x' do "dl". (Christian Brabandt, closes #4927)
1 parent 705918f commit 7a9bd7c

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/normal.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7381,8 +7381,8 @@ nv_optrans(cmdarg_T *cap)
73817381

73827382
if (!checkclearopq(cap->oap))
73837383
{
7384-
/* In Vi "2D" doesn't delete the next line. Can't translate it
7385-
* either, because "2." should also not use the count. */
7384+
// In Vi "2D" doesn't delete the next line. Can't translate it
7385+
// either, because "2." should also not use the count.
73867386
if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL)
73877387
{
73887388
cap->oap->start = curwin->w_cursor;
@@ -7400,7 +7400,13 @@ nv_optrans(cmdarg_T *cap)
74007400
{
74017401
if (cap->count0)
74027402
stuffnumReadbuff(cap->count0);
7403-
stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
7403+
// If on an empty line and using 'x' and "l" is included in the
7404+
// whichwrap option, do not delete the next line.
7405+
if (cap->cmdchar == 'x' && vim_strchr(p_ww, 'l') != NULL
7406+
&& gchar_cursor() == NUL)
7407+
stuffReadbuff((char_u *)"dd");
7408+
else
7409+
stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
74047410
}
74057411
}
74067412
cap->opcount = 0;

src/testdir/test_fold.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,15 @@ func Test_fold_delete_with_marker()
757757
bwipe!
758758
bwipe!
759759
endfunc
760+
761+
func Test_fold_delete_with_marker_and_whichwrap()
762+
new
763+
let content1 = ['']
764+
let content2 = ['folded line 1 "{{{1', ' test', ' test2', ' test3', '', 'folded line 2 "{{{1', ' test', ' test2', ' test3']
765+
call setline(1, content1 + content2)
766+
set fdm=marker ww+=l
767+
normal! x
768+
call assert_equal(content2, getline(1, '$'))
769+
set fdm& ww&
770+
bwipe!
771+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
2052,
760762
/**/
761763
2051,
762764
/**/

0 commit comments

Comments
 (0)