]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5009: fold may not be closeable after appending v8.2.5009
authorBrandon Simmons <simmsbra@gmail.com>
Mon, 23 May 2022 14:33:08 +0000 (15:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 23 May 2022 14:33:08 +0000 (15:33 +0100)
Problem:    Fold may not be closeable after appending.
Solution:   Set the fd_small flag to MAYBE. (Brandon Simmons, closes #10471)

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

index 26a4a98a76ca37a2c471933285d1f8d6f12282ad..ee94a979f06a397511f269d2a8108875a96b4a9c 100644 (file)
@@ -2574,6 +2574,7 @@ foldUpdateIEMSRecurse(
                                        (long)(fp->fd_top - firstlnum));
                            fp->fd_len += fp->fd_top - firstlnum;
                            fp->fd_top = firstlnum;
+                           fp->fd_small = MAYBE;
                            fold_changed = TRUE;
                        }
                        else if ((flp->start != 0 && lvl == level)
index 67a399ddd8350a9a5f264a65eab0ed5683a8be33..3bdd99fc0ede073f47999a5c7c3e3d0f91dc7c80 100644 (file)
@@ -1528,4 +1528,23 @@ func Test_indent_one_line_fold_close()
   bw!
 endfunc
 
+" Make sure that when appending [an indented line then a blank line] right
+" before a single indented line, the resulting extended fold can be closed
+func Test_indent_append_blank_small_fold_close()
+  new
+  setlocal sw=2 foldmethod=indent
+  " at first, the fold at the second line can't be closed since it's smaller
+  " than foldminlines
+  let lines =<< trim END
+    line 1
+      line 4
+  END
+  call setline(1, lines)
+  call append(1, ['  line 2', ''])
+  " close all folds
+  normal zM
+  call assert_notequal(-1, foldclosed(2)) " the fold should be closed now
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 36350c3b350c122c009f8ba11c4941e6b655caad..07f1b5d63f043b03e6d30e85ec09fe0f71c145c1 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5009,
 /**/
     5008,
 /**/