Patch 8.2.4987
Problem:    After deletion a small fold may be closable.
Solution:   Check for a reverse range. (Brandon Simmons, closes #10457)
Files:      src/fold.c, src/testdir/test_fold.vim


*** ../vim-8.2.4986/src/fold.c  2022-05-10 19:13:19.670926903 +0100
--- src/fold.c  2022-05-20 18:24:51.913292745 +0100
***************
*** 829,838 ****
  
      if (wp->w_folds.ga_len > 0)
      {
!       // Mark all folds from top to bot as maybe-small.
!       (void)foldFind(&wp->w_folds, top, &fp);
        while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
!               && fp->fd_top < bot)
        {
            fp->fd_small = MAYBE;
            ++fp;
--- 829,846 ----
  
      if (wp->w_folds.ga_len > 0)
      {
!       linenr_T        maybe_small_start = top;
!       linenr_T        maybe_small_end = bot;
! 
!       // Mark all folds from top to bot (or bot to top) as maybe-small.
!       if (top > bot)
!       {
!           maybe_small_start = bot;
!           maybe_small_end = top;
!       }
!       (void)foldFind(&wp->w_folds, maybe_small_start, &fp);
        while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
!               && fp->fd_top <= maybe_small_end)
        {
            fp->fd_small = MAYBE;
            ++fp;
***************
*** 2165,2171 ****
        bot = wp->w_buffer->b_ml.ml_line_count;
        wp->w_foldinvalid = FALSE;
  
!       // Mark all folds a maybe-small.
        setSmallMaybe(&wp->w_folds);
      }
  
--- 2173,2179 ----
        bot = wp->w_buffer->b_ml.ml_line_count;
        wp->w_foldinvalid = FALSE;
  
!       // Mark all folds as maybe-small.
        setSmallMaybe(&wp->w_folds);
      }
  
*** ../vim-8.2.4986/src/testdir/test_fold.vim   2022-05-10 19:13:19.670926903 
+0100
--- src/testdir/test_fold.vim   2022-05-20 18:12:00.327631989 +0100
***************
*** 1479,1482 ****
--- 1479,1511 ----
    bw!
  endfunc
  
+ " Make sure that when you delete 1 line of a fold whose length is 2 lines, the
+ " fold can't be closed since its length (1) is now less than foldminlines.
+ func Test_indent_one_line_fold_close()
+   let lines =<< trim END
+     line 1
+       line 2
+       line 3
+   END
+ 
+   new
+   setlocal sw=2 foldmethod=indent
+   call setline(1, lines)
+   " open all folds, delete line, then close all folds
+   normal zR
+   3delete
+   normal zM
+   call assert_equal(-1, foldclosed(2)) " the fold should not be closed
+ 
+   " Now do the same, but delete line 2 this time; this covers different code.
+   " (Combining this code with the above code doesn't expose both bugs.)
+   1,$delete
+   call setline(1, lines)
+   normal zR
+   2delete
+   normal zM
+   call assert_equal(-1, foldclosed(2))
+   bw!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4986/src/version.c       2022-05-20 17:19:02.680498940 +0100
--- src/version.c       2022-05-20 18:14:06.255117588 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4987,
  /**/

-- 
A man is incomplete until he's married ... and then he's finished!

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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/20220520172617.3447D1C088A%40moolenaar.net.

Raspunde prin e-mail lui