Patch 8.0.0388
Problem:    filtering lines through "cat", without changing the line count,
            changes manual folds.
Solution:   Change how marks and folds are adjusted. (Matthew Malcomson, from
            neovim #6194.
Files:      src/fold.c, src/testdir/test_fold.vim


*** ../vim-8.0.0387/src/fold.c  2016-08-29 22:42:20.000000000 +0200
--- src/fold.c  2017-02-28 21:49:29.553420143 +0100
***************
*** 1576,1591 ****
                {
                    /* 5. fold is below line1 and contains line2; need to
                     * correct nested folds too */
-                   foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
-                                 line2 - fp->fd_top, amount,
-                                 amount_after + (fp->fd_top - top));
                    if (amount == MAXLNUM)
                    {
                        fp->fd_len -= line2 - fp->fd_top + 1;
                        fp->fd_top = line1;
                    }
                    else
                    {
                        fp->fd_len += amount_after - amount;
                        fp->fd_top += amount;
                    }
--- 1576,1598 ----
                {
                    /* 5. fold is below line1 and contains line2; need to
                     * correct nested folds too */
                    if (amount == MAXLNUM)
                    {
+                       foldMarkAdjustRecurse(&fp->fd_nested,
+                                 line1 - fp->fd_top,
+                                 line2 - fp->fd_top,
+                                 amount,
+                                 amount_after + (fp->fd_top - top));
                        fp->fd_len -= line2 - fp->fd_top + 1;
                        fp->fd_top = line1;
                    }
                    else
                    {
+                       foldMarkAdjustRecurse(&fp->fd_nested,
+                                 line1 - fp->fd_top,
+                                 line2 - fp->fd_top,
+                                 amount,
+                                 amount_after - amount);
                        fp->fd_len += amount_after - amount;
                        fp->fd_top += amount;
                    }
*** ../vim-8.0.0387/src/testdir/test_fold.vim   2017-01-02 14:57:05.494810156 
+0100
--- src/testdir/test_fold.vim   2017-02-28 21:45:38.099010024 +0100
***************
*** 1,6 ****
  " Test for folding
  
! function! Test_address_fold()
    new
    call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
              \ 'after fold 1', 'after fold 2', 'after fold 3'])
--- 1,6 ----
  " Test for folding
  
! func! Test_address_fold()
    new
    call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
              \ 'after fold 1', 'after fold 2', 'after fold 3'])
***************
*** 62,70 ****
    call assert_equal(['4', '5', '}/*}}}*/'], getreg(0,1,1))
  
    quit!
! endfunction
  
! function! Test_indent_fold()
      new
      call setline(1, ['', 'a', '    b', '    c'])
      setl fen fdm=indent
--- 62,70 ----
    call assert_equal(['4', '5', '}/*}}}*/'], getreg(0,1,1))
  
    quit!
! endfunc
  
! func! Test_indent_fold()
      new
      call setline(1, ['', 'a', '    b', '    c'])
      setl fen fdm=indent
***************
*** 72,80 ****
      norm! >>
      let a=map(range(1,4), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,-1], a)
! endfu
  
! function! Test_indent_fold()
      new
      call setline(1, ['', 'a', '    b', '    c'])
      setl fen fdm=indent
--- 72,80 ----
      norm! >>
      let a=map(range(1,4), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,-1], a)
! endfunc
  
! func! Test_indent_fold()
      new
      call setline(1, ['', 'a', '    b', '    c'])
      setl fen fdm=indent
***************
*** 83,91 ****
      let a=map(range(1,4), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,-1], a)
      bw!
! endfu
  
! function! Test_indent_fold2()
      new
      call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
      setl fen fdm=marker
--- 83,91 ----
      let a=map(range(1,4), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,-1], a)
      bw!
! endfunc
  
! func! Test_indent_fold2()
      new
      call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
      setl fen fdm=marker
***************
*** 94,97 ****
      let a=map(range(1,5), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,4,4], a)
      bw!
! endfu
--- 94,114 ----
      let a=map(range(1,5), 'foldclosed(v:val)')
      call assert_equal([-1,-1,-1,4,4], a)
      bw!
! endfunc
! 
! func Test_manual_fold_with_filter()
!   if !executable('cat')
!     return
!   endif
!   new
!   call setline(1, range(1, 20))
!   4,$fold
!   %foldopen
!   10,$fold
!   %foldopen
!   " This filter command should not have an effect
!   1,8! cat
!   call feedkeys('5ggzdzMGdd', 'xt')
!   call assert_equal(['1', '2', '3', '4', '5', '6', '7', '8', '9'], getline(1, 
'$'))
!   bwipe!
! endfunc
*** ../vim-8.0.0387/src/version.c       2017-02-28 21:26:12.826899315 +0100
--- src/version.c       2017-02-28 21:52:28.440193664 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     388,
  /**/

-- 
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
                -- Arthur Dent and Ford Prefect in Douglas Adams'
                   "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui