2ce6b39
To: vim-dev@vim.org
2ce6b39
Subject: Patch 7.2.370
2ce6b39
Fcc: outbox
2ce6b39
From: Bram Moolenaar <Bram@moolenaar.net>
2ce6b39
Mime-Version: 1.0
2ce6b39
Content-Type: text/plain; charset=UTF-8
2ce6b39
Content-Transfer-Encoding: 8bit
2ce6b39
------------
2ce6b39
2ce6b39
Patch 7.2.370 (after 7.2.356)
2ce6b39
Problem:    A redraw may cause folds to be closed.
2ce6b39
Solution:   Revert part of the previous patch.  Add a test. (Lech Lorens)
2ce6b39
Files:	    src/diff.c, src/fold.c, src/option.c, src/testdir/test45.in,
2ce6b39
	    src/testdir/test45.ok
2ce6b39
2ce6b39
2ce6b39
*** ../vim-7.2.369/src/diff.c	2009-07-22 16:22:33.000000000 +0200
2ce6b39
--- src/diff.c	2010-02-24 14:31:12.000000000 +0100
2ce6b39
***************
2ce6b39
*** 1117,1142 ****
2ce6b39
      win_T	*wp;
2ce6b39
      int		addbuf;		/* Add buffer to diff. */
2ce6b39
  {
2ce6b39
      wp->w_p_diff = TRUE;
2ce6b39
      wp->w_p_scb = TRUE;
2ce6b39
      wp->w_p_wrap = FALSE;
2ce6b39
  # ifdef FEAT_FOLDING
2ce6b39
!     {
2ce6b39
! 	win_T	    *old_curwin = curwin;
2ce6b39
! 
2ce6b39
! 	curwin = wp;
2ce6b39
! 	curbuf = curwin->w_buffer;
2ce6b39
! 	set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
2ce6b39
  						       OPT_LOCAL|OPT_FREE, 0);
2ce6b39
! 	curwin = old_curwin;
2ce6b39
! 	curbuf = curwin->w_buffer;
2ce6b39
! 	wp->w_p_fdc = diff_foldcolumn;
2ce6b39
! 	wp->w_p_fen = TRUE;
2ce6b39
! 	wp->w_p_fdl = 0;
2ce6b39
! 	foldUpdateAll(wp);
2ce6b39
! 	/* make sure topline is not halfway a fold */
2ce6b39
! 	changed_window_setting_win(wp);
2ce6b39
!     }
2ce6b39
  # endif
2ce6b39
  #ifdef FEAT_SCROLLBIND
2ce6b39
      if (vim_strchr(p_sbo, 'h') == NULL)
2ce6b39
--- 1117,1147 ----
2ce6b39
      win_T	*wp;
2ce6b39
      int		addbuf;		/* Add buffer to diff. */
2ce6b39
  {
2ce6b39
+ # ifdef FEAT_FOLDING
2ce6b39
+     win_T *old_curwin = curwin;
2ce6b39
+ 
2ce6b39
+     /* close the manually opened folds */
2ce6b39
+     curwin = wp;
2ce6b39
+     newFoldLevel();
2ce6b39
+     curwin = old_curwin;
2ce6b39
+ # endif
2ce6b39
+ 
2ce6b39
      wp->w_p_diff = TRUE;
2ce6b39
      wp->w_p_scb = TRUE;
2ce6b39
      wp->w_p_wrap = FALSE;
2ce6b39
  # ifdef FEAT_FOLDING
2ce6b39
!     curwin = wp;
2ce6b39
!     curbuf = curwin->w_buffer;
2ce6b39
!     set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
2ce6b39
  						       OPT_LOCAL|OPT_FREE, 0);
2ce6b39
!     curwin = old_curwin;
2ce6b39
!     curbuf = curwin->w_buffer;
2ce6b39
!     wp->w_p_fdc = diff_foldcolumn;
2ce6b39
!     wp->w_p_fen = TRUE;
2ce6b39
!     wp->w_p_fdl = 0;
2ce6b39
!     foldUpdateAll(wp);
2ce6b39
!     /* make sure topline is not halfway a fold */
2ce6b39
!     changed_window_setting_win(wp);
2ce6b39
  # endif
2ce6b39
  #ifdef FEAT_SCROLLBIND
2ce6b39
      if (vim_strchr(p_sbo, 'h') == NULL)
2ce6b39
*** ../vim-7.2.369/src/fold.c	2010-02-03 18:14:41.000000000 +0100
2ce6b39
--- src/fold.c	2010-02-24 13:09:04.000000000 +0100
2ce6b39
***************
2ce6b39
*** 854,865 ****
2ce6b39
  	    && fp->fd_top < bot)
2ce6b39
      {
2ce6b39
  	fp->fd_small = MAYBE;
2ce6b39
- 
2ce6b39
- 	/* Not sure if this is the right place to reset fd_flags (suggested by
2ce6b39
- 	 * Lech Lorens). */
2ce6b39
-         if (wp->w_foldinvalid)
2ce6b39
-             fp->fd_flags = FD_LEVEL;
2ce6b39
- 
2ce6b39
  	++fp;
2ce6b39
      }
2ce6b39
  
2ce6b39
--- 854,859 ----
2ce6b39
*** ../vim-7.2.369/src/option.c	2010-02-11 17:02:04.000000000 +0100
2ce6b39
--- src/option.c	2010-02-24 13:09:44.000000000 +0100
2ce6b39
***************
2ce6b39
*** 6586,6592 ****
2ce6b39
--- 6586,6596 ----
2ce6b39
  		|| *curwin->w_p_fdm == NUL)
2ce6b39
  	    errmsg = e_invarg;
2ce6b39
  	else
2ce6b39
+ 	{
2ce6b39
  	    foldUpdateAll(curwin);
2ce6b39
+ 	    if (foldmethodIsDiff(curwin))
2ce6b39
+ 		newFoldLevel();
2ce6b39
+ 	}
2ce6b39
      }
2ce6b39
  # ifdef FEAT_EVAL
2ce6b39
      /* 'foldexpr' */
2ce6b39
*** ../vim-7.2.369/src/testdir/test45.in	2009-11-03 14:46:35.000000000 +0100
2ce6b39
--- src/testdir/test45.in	2010-02-24 13:02:39.000000000 +0100
2ce6b39
***************
2ce6b39
*** 36,41 ****
2ce6b39
--- 36,43 ----
2ce6b39
  k:call append("$", getline("."))
2ce6b39
  jAcommentstart  ?Acommentend?:set fdl=1
2ce6b39
  3j:call append("$", getline("."))
2ce6b39
+ :set fdl=0
2ce6b39
+ zO?j:call append("$", getline("."))
2ce6b39
  :" test expression folding
2ce6b39
  :fun Flvl()
2ce6b39
    let l = getline(v:lnum)
2ce6b39
*** ../vim-7.2.369/src/testdir/test45.ok	2009-11-03 14:46:35.000000000 +0100
2ce6b39
--- src/testdir/test45.ok	2010-02-24 12:58:55.000000000 +0100
2ce6b39
***************
2ce6b39
*** 11,16 ****
2ce6b39
--- 11,17 ----
2ce6b39
  folding 9 ii
2ce6b39
      3 cc
2ce6b39
  7 gg
2ce6b39
+ 8 hh
2ce6b39
  expr 2
2ce6b39
  1
2ce6b39
  2
2ce6b39
*** ../vim-7.2.369/src/version.c	2010-02-24 13:59:09.000000000 +0100
2ce6b39
--- src/version.c	2010-02-24 14:28:20.000000000 +0100
2ce6b39
***************
2ce6b39
*** 683,684 ****
2ce6b39
--- 683,686 ----
2ce6b39
  {   /* Add new patch number below this line */
2ce6b39
+ /**/
2ce6b39
+     370,
2ce6b39
  /**/
2ce6b39
2ce6b39
-- 
2ce6b39
MAN:    Fetchez la vache!
2ce6b39
GUARD:  Quoi?
2ce6b39
MAN:    Fetchez la vache!
2ce6b39
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
2ce6b39
2ce6b39
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
2ce6b39
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
2ce6b39
\\\        download, build and distribute -- http://www.A-A-P.org        ///
2ce6b39
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///