Karsten Hopp 91d9c0
To: vim_dev@googlegroups.com
Karsten Hopp 91d9c0
Subject: Patch 7.4.768
Karsten Hopp 91d9c0
Fcc: outbox
Karsten Hopp 91d9c0
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 91d9c0
Mime-Version: 1.0
Karsten Hopp 91d9c0
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 91d9c0
Content-Transfer-Encoding: 8bit
Karsten Hopp 91d9c0
------------
Karsten Hopp 91d9c0
Karsten Hopp 91d9c0
Patch 7.4.768
Karsten Hopp 91d9c0
Problem:    :diffoff only works properly once.
Karsten Hopp 91d9c0
Solution:   Also make :diffoff work when used a second time. (Olaf Dabrunz)
Karsten Hopp 91d9c0
Files:      src/diff.c
Karsten Hopp 91d9c0
Karsten Hopp 91d9c0
Karsten Hopp 91d9c0
*** ../vim-7.4.767/src/diff.c	2015-03-31 13:33:00.781525085 +0200
Karsten Hopp 91d9c0
--- src/diff.c	2015-07-03 14:55:54.953220651 +0200
Karsten Hopp 91d9c0
***************
Karsten Hopp 91d9c0
*** 1138,1169 ****
Karsten Hopp 91d9c0
      curwin = old_curwin;
Karsten Hopp 91d9c0
  # endif
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
-     wp->w_p_diff = TRUE;
Karsten Hopp 91d9c0
- 
Karsten Hopp 91d9c0
      /* Use 'scrollbind' and 'cursorbind' when available */
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff_saved)
Karsten Hopp 91d9c0
  	wp->w_p_scb_save = wp->w_p_scb;
Karsten Hopp 91d9c0
      wp->w_p_scb = TRUE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
  #ifdef FEAT_CURSORBIND
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff_saved)
Karsten Hopp 91d9c0
  	wp->w_p_crb_save = wp->w_p_crb;
Karsten Hopp 91d9c0
      wp->w_p_crb = TRUE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff_saved)
Karsten Hopp 91d9c0
  	wp->w_p_wrap_save = wp->w_p_wrap;
Karsten Hopp 91d9c0
      wp->w_p_wrap = FALSE;
Karsten Hopp 91d9c0
  # ifdef FEAT_FOLDING
Karsten Hopp 91d9c0
      curwin = wp;
Karsten Hopp 91d9c0
      curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff_saved)
Karsten Hopp 91d9c0
  	wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
Karsten Hopp 91d9c0
      set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
Karsten Hopp 91d9c0
  						       OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 91d9c0
      curwin = old_curwin;
Karsten Hopp 91d9c0
      curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff_saved)
Karsten Hopp 91d9c0
      {
Karsten Hopp 91d9c0
  	wp->w_p_fdc_save = wp->w_p_fdc;
Karsten Hopp 91d9c0
  	wp->w_p_fen_save = wp->w_p_fen;
Karsten Hopp 91d9c0
--- 1138,1171 ----
Karsten Hopp 91d9c0
      curwin = old_curwin;
Karsten Hopp 91d9c0
  # endif
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
      /* Use 'scrollbind' and 'cursorbind' when available */
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff)
Karsten Hopp 91d9c0
  	wp->w_p_scb_save = wp->w_p_scb;
Karsten Hopp 91d9c0
      wp->w_p_scb = TRUE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
  #ifdef FEAT_CURSORBIND
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff)
Karsten Hopp 91d9c0
  	wp->w_p_crb_save = wp->w_p_crb;
Karsten Hopp 91d9c0
      wp->w_p_crb = TRUE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff)
Karsten Hopp 91d9c0
  	wp->w_p_wrap_save = wp->w_p_wrap;
Karsten Hopp 91d9c0
      wp->w_p_wrap = FALSE;
Karsten Hopp 91d9c0
  # ifdef FEAT_FOLDING
Karsten Hopp 91d9c0
      curwin = wp;
Karsten Hopp 91d9c0
      curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff)
Karsten Hopp 91d9c0
!     {
Karsten Hopp 91d9c0
! 	if (wp->w_p_diff_saved)
Karsten Hopp 91d9c0
! 	    free_string_option(wp->w_p_fdm_save);
Karsten Hopp 91d9c0
  	wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
Karsten Hopp 91d9c0
+     }
Karsten Hopp 91d9c0
      set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
Karsten Hopp 91d9c0
  						       OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 91d9c0
      curwin = old_curwin;
Karsten Hopp 91d9c0
      curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
!     if (!wp->w_p_diff)
Karsten Hopp 91d9c0
      {
Karsten Hopp 91d9c0
  	wp->w_p_fdc_save = wp->w_p_fdc;
Karsten Hopp 91d9c0
  	wp->w_p_fen_save = wp->w_p_fen;
Karsten Hopp 91d9c0
***************
Karsten Hopp 91d9c0
*** 1183,1188 ****
Karsten Hopp 91d9c0
--- 1185,1192 ----
Karsten Hopp 91d9c0
      /* Saved the current values, to be restored in ex_diffoff(). */
Karsten Hopp 91d9c0
      wp->w_p_diff_saved = TRUE;
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
+     wp->w_p_diff = TRUE;
Karsten Hopp 91d9c0
+ 
Karsten Hopp 91d9c0
      if (addbuf)
Karsten Hopp 91d9c0
  	diff_buf_add(wp->w_buffer);
Karsten Hopp 91d9c0
      redraw_win_later(wp, NOT_VALID);
Karsten Hopp 91d9c0
***************
Karsten Hopp 91d9c0
*** 1197,1203 ****
Karsten Hopp 91d9c0
      exarg_T	*eap;
Karsten Hopp 91d9c0
  {
Karsten Hopp 91d9c0
      win_T	*wp;
Karsten Hopp 91d9c0
-     win_T	*old_curwin = curwin;
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
      int		diffwin = FALSE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
--- 1201,1206 ----
Karsten Hopp 91d9c0
***************
Karsten Hopp 91d9c0
*** 1206,1262 ****
Karsten Hopp 91d9c0
      {
Karsten Hopp 91d9c0
  	if (eap->forceit ? wp->w_p_diff : wp == curwin)
Karsten Hopp 91d9c0
  	{
Karsten Hopp 91d9c0
! 	    /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
Karsten Hopp 91d9c0
! 	     * were saved in diff_win_options() restore them. */
Karsten Hopp 91d9c0
  	    wp->w_p_diff = FALSE;
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
! 	    if (wp->w_p_scb)
Karsten Hopp 91d9c0
! 		wp->w_p_scb = wp->w_p_diff_saved ? wp->w_p_scb_save : FALSE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
  #ifdef FEAT_CURSORBIND
Karsten Hopp 91d9c0
! 	    if (wp->w_p_crb)
Karsten Hopp 91d9c0
! 		wp->w_p_crb = wp->w_p_diff_saved ? wp->w_p_crb_save : FALSE;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
! 	    if (!wp->w_p_wrap)
Karsten Hopp 91d9c0
! 		wp->w_p_wrap = wp->w_p_diff_saved ? wp->w_p_wrap_save : TRUE;
Karsten Hopp 91d9c0
  #ifdef FEAT_FOLDING
Karsten Hopp 91d9c0
- 	    curwin = wp;
Karsten Hopp 91d9c0
- 	    curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
- 	    if (wp->w_p_diff_saved)
Karsten Hopp 91d9c0
- 	    {
Karsten Hopp 91d9c0
  		free_string_option(wp->w_p_fdm);
Karsten Hopp 91d9c0
! 		wp->w_p_fdm = wp->w_p_fdm_save;
Karsten Hopp 91d9c0
! 		wp->w_p_fdm_save = empty_option;
Karsten Hopp 91d9c0
! 	    }
Karsten Hopp 91d9c0
! 	    else
Karsten Hopp 91d9c0
! 		set_string_option_direct((char_u *)"fdm", -1,
Karsten Hopp 91d9c0
! 				   (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 91d9c0
! 	    curwin = old_curwin;
Karsten Hopp 91d9c0
! 	    curbuf = curwin->w_buffer;
Karsten Hopp 91d9c0
! 	    if (wp->w_p_fdc == diff_foldcolumn)
Karsten Hopp 91d9c0
! 		wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0;
Karsten Hopp 91d9c0
! 	    if (wp->w_p_fdl == 0 && wp->w_p_diff_saved)
Karsten Hopp 91d9c0
! 		wp->w_p_fdl = wp->w_p_fdl_save;
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
- 	    if (wp->w_p_fen)
Karsten Hopp 91d9c0
- 	    {
Karsten Hopp 91d9c0
  		/* Only restore 'foldenable' when 'foldmethod' is not
Karsten Hopp 91d9c0
  		 * "manual", otherwise we continue to show the diff folds. */
Karsten Hopp 91d9c0
! 		if (foldmethodIsManual(wp) || !wp->w_p_diff_saved)
Karsten Hopp 91d9c0
! 		    wp->w_p_fen = FALSE;
Karsten Hopp 91d9c0
! 		else
Karsten Hopp 91d9c0
! 		    wp->w_p_fen = wp->w_p_fen_save;
Karsten Hopp 91d9c0
  	    }
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
- 	    foldUpdateAll(wp);
Karsten Hopp 91d9c0
- 	    /* make sure topline is not halfway a fold */
Karsten Hopp 91d9c0
- 	    changed_window_setting_win(wp);
Karsten Hopp 91d9c0
- #endif
Karsten Hopp 91d9c0
  	    /* Note: 'sbo' is not restored, it's a global option. */
Karsten Hopp 91d9c0
  	    diff_buf_adjust(wp);
Karsten Hopp 91d9c0
- 
Karsten Hopp 91d9c0
- 	    wp->w_p_diff_saved = FALSE;
Karsten Hopp 91d9c0
  	}
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
  	diffwin |= wp->w_p_diff;
Karsten Hopp 91d9c0
--- 1209,1255 ----
Karsten Hopp 91d9c0
      {
Karsten Hopp 91d9c0
  	if (eap->forceit ? wp->w_p_diff : wp == curwin)
Karsten Hopp 91d9c0
  	{
Karsten Hopp 91d9c0
! 	    /* Set 'diff' off. If option values were saved in
Karsten Hopp 91d9c0
! 	     * diff_win_options(), restore the ones whose settings seem to have
Karsten Hopp 91d9c0
! 	     * been left over from diff mode.  */
Karsten Hopp 91d9c0
  	    wp->w_p_diff = FALSE;
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
+ 	    if (wp->w_p_diff_saved)
Karsten Hopp 91d9c0
+ 	    {
Karsten Hopp 91d9c0
+ 
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
! 		if (wp->w_p_scb)
Karsten Hopp 91d9c0
! 		    wp->w_p_scb = wp->w_p_scb_save;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
  #ifdef FEAT_CURSORBIND
Karsten Hopp 91d9c0
! 		if (wp->w_p_crb)
Karsten Hopp 91d9c0
! 		    wp->w_p_crb = wp->w_p_crb_save;
Karsten Hopp 91d9c0
  #endif
Karsten Hopp 91d9c0
! 		if (!wp->w_p_wrap)
Karsten Hopp 91d9c0
! 		    wp->w_p_wrap = wp->w_p_wrap_save;
Karsten Hopp 91d9c0
  #ifdef FEAT_FOLDING
Karsten Hopp 91d9c0
  		free_string_option(wp->w_p_fdm);
Karsten Hopp 91d9c0
! 		wp->w_p_fdm = vim_strsave(wp->w_p_fdm_save);
Karsten Hopp 91d9c0
! 
Karsten Hopp 91d9c0
! 		if (wp->w_p_fdc == diff_foldcolumn)
Karsten Hopp 91d9c0
! 		    wp->w_p_fdc = wp->w_p_fdc_save;
Karsten Hopp 91d9c0
! 		if (wp->w_p_fdl == 0)
Karsten Hopp 91d9c0
! 		    wp->w_p_fdl = wp->w_p_fdl_save;
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
  		/* Only restore 'foldenable' when 'foldmethod' is not
Karsten Hopp 91d9c0
  		 * "manual", otherwise we continue to show the diff folds. */
Karsten Hopp 91d9c0
! 		if (wp->w_p_fen)
Karsten Hopp 91d9c0
! 		    wp->w_p_fen = foldmethodIsManual(wp) ? FALSE
Karsten Hopp 91d9c0
! 							 : wp->w_p_fen_save;
Karsten Hopp 91d9c0
! 
Karsten Hopp 91d9c0
! 		foldUpdateAll(wp);
Karsten Hopp 91d9c0
! 		/* make sure topline is not halfway a fold */
Karsten Hopp 91d9c0
! 		changed_window_setting_win(wp);
Karsten Hopp 91d9c0
! #endif
Karsten Hopp 91d9c0
  	    }
Karsten Hopp 91d9c0
  
Karsten Hopp 91d9c0
  	    /* Note: 'sbo' is not restored, it's a global option. */
Karsten Hopp 91d9c0
  	    diff_buf_adjust(wp);
Karsten Hopp 91d9c0
  	}
Karsten Hopp 91d9c0
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 91d9c0
  	diffwin |= wp->w_p_diff;
Karsten Hopp 91d9c0
*** ../vim-7.4.767/src/version.c	2015-07-03 13:32:56.125020856 +0200
Karsten Hopp 91d9c0
--- src/version.c	2015-07-03 14:54:09.850320403 +0200
Karsten Hopp 91d9c0
***************
Karsten Hopp 91d9c0
*** 743,744 ****
Karsten Hopp 91d9c0
--- 743,746 ----
Karsten Hopp 91d9c0
  {   /* Add new patch number below this line */
Karsten Hopp 91d9c0
+ /**/
Karsten Hopp 91d9c0
+     768,
Karsten Hopp 91d9c0
  /**/
Karsten Hopp 91d9c0
Karsten Hopp 91d9c0
-- 
Karsten Hopp 91d9c0
If Apple would build a car...
Karsten Hopp 91d9c0
... it would be powered by the sun, be reliable, five times
Karsten Hopp 91d9c0
as fast and twice as easy to drive; but would only run on
Karsten Hopp 91d9c0
five percent of the roads.
Karsten Hopp 91d9c0
Karsten Hopp 91d9c0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 91d9c0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 91d9c0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 91d9c0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///