]> granicus.if.org Git - vim/commitdiff
patch 8.2.0002: "dj" only deletes first line of closed fold v8.2.0002
authorBram Moolenaar <Bram@vim.org>
Fri, 13 Dec 2019 18:35:55 +0000 (19:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 13 Dec 2019 18:35:55 +0000 (19:35 +0100)
Problem:    "dj" only deletes first line of closed fold.
Solution:   Adjust last line of operator for linewise motion. (closes #5354)

src/ops.c
src/testdir/test_fold.vim
src/version.c

index d3e1e47f32218861096f2be34f83948e37018463..2a625066c45173ffb3b8f21b106cc42314db1476 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -4233,7 +4233,8 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
            {
                if (hasFolding(oap->start.lnum, &oap->start.lnum, NULL))
                    oap->start.col = 0;
-               if ((curwin->w_cursor.col > 0 || oap->inclusive)
+               if ((curwin->w_cursor.col > 0 || oap->inclusive
+                                                 || oap->motion_type == MLINE)
                        && hasFolding(curwin->w_cursor.lnum, NULL,
                                                      &curwin->w_cursor.lnum))
                    curwin->w_cursor.col = (colnr_T)STRLEN(ml_get_curline());
index 824a4f22f6bcaebcdcfbe66487bfe3733e09abc5..36de13656c35be40eb998e795b779a41835e2042 100644 (file)
@@ -769,3 +769,28 @@ func Test_fold_delete_with_marker_and_whichwrap()
   set fdm& ww&
   bwipe!
 endfunc
+
+func Test_fold_delete_first_line()
+  new
+  call setline(1, [
+       \ '" x {{{1',
+       \ '" a',
+       \ '" aa',
+       \ '" x {{{1',
+       \ '" b',
+       \ '" bb',
+       \ '" x {{{1',
+       \ '" c',
+       \ '" cc',
+       \ ])
+  set foldmethod=marker
+  1
+  normal dj
+  call assert_equal([
+       \ '" x {{{1',
+       \ '" c',
+       \ '" cc',
+       \ ], getline(1,'$'))
+  bwipe!
+  set foldmethod&
+endfunc
index b3f1fdb96b1fa8bd2df87f71445b0b8fe34f26c6..4573e5af47d7dc38fddb1f7a434cf6a32f5d9a2e 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2,
 /**/
     1,
 /**/