diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-17 22:42:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-17 22:42:55 +0200 |
commit | 7a9bd7c1e0ce1baf5a02daf36eeae3638aa315c7 (patch) | |
tree | ff28a87ff9894a452f2f27c938c1370f958c16da /src | |
parent | 705918f9f7e446287923cf0248ea35f2a0688199 (diff) |
patch 8.1.2052: using "x" before a closed fold may delete that foldv8.1.2052
Problem: Using "x" before a closed fold may delete that fold.
Solution: Do not translate 'x' do "dl". (Christian Brabandt, closes #4927)
Diffstat (limited to 'src')
-rw-r--r-- | src/normal.c | 12 | ||||
-rw-r--r-- | src/testdir/test_fold.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/normal.c b/src/normal.c index d169f260a2..e83c4c0be9 100644 --- a/src/normal.c +++ b/src/normal.c @@ -7381,8 +7381,8 @@ nv_optrans(cmdarg_T *cap) if (!checkclearopq(cap->oap)) { - /* In Vi "2D" doesn't delete the next line. Can't translate it - * either, because "2." should also not use the count. */ + // In Vi "2D" doesn't delete the next line. Can't translate it + // either, because "2." should also not use the count. if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) { cap->oap->start = curwin->w_cursor; @@ -7400,7 +7400,13 @@ nv_optrans(cmdarg_T *cap) { if (cap->count0) stuffnumReadbuff(cap->count0); - stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); + // 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)]); } } cap->opcount = 0; diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index 7aef51f8bd..824a4f22f6 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -757,3 +757,15 @@ func Test_fold_delete_with_marker() bwipe! bwipe! endfunc + +func Test_fold_delete_with_marker_and_whichwrap() + new + let content1 = [''] + let content2 = ['folded line 1 "{{{1', ' test', ' test2', ' test3', '', 'folded line 2 "{{{1', ' test', ' test2', ' test3'] + call setline(1, content1 + content2) + set fdm=marker ww+=l + normal! x + call assert_equal(content2, getline(1, '$')) + set fdm& ww& + bwipe! +endfunc diff --git a/src/version.c b/src/version.c index af656f282c..c0d161aac1 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2052, +/**/ 2051, /**/ 2050, |