Karsten Hopp 9faa99
To: vim_dev@googlegroups.com
Karsten Hopp 9faa99
Subject: Patch 7.3.1294
Karsten Hopp 9faa99
Fcc: outbox
Karsten Hopp 9faa99
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 9faa99
Mime-Version: 1.0
Karsten Hopp 9faa99
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 9faa99
Content-Transfer-Encoding: 8bit
Karsten Hopp 9faa99
------------
Karsten Hopp 9faa99
Karsten Hopp 9faa99
Patch 7.3.1294
Karsten Hopp 9faa99
Problem:    ":diffoff" resets options.
Karsten Hopp 9faa99
Solution:   Save and restore option values. (Christian Brabandt)
Karsten Hopp 9faa99
Files:	    src/diff.c, src/structs.h, src/option.c
Karsten Hopp 9faa99
Karsten Hopp 9faa99
Karsten Hopp 9faa99
*** ../vim-7.3.1293/src/diff.c	2013-05-06 04:21:35.000000000 +0200
Karsten Hopp 9faa99
--- src/diff.c	2013-07-03 15:23:18.000000000 +0200
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 1138,1158 ****
Karsten Hopp 9faa99
--- 1138,1173 ----
Karsten Hopp 9faa99
  # endif
Karsten Hopp 9faa99
  
Karsten Hopp 9faa99
      wp->w_p_diff = TRUE;
Karsten Hopp 9faa99
+ 
Karsten Hopp 9faa99
      /* Use 'scrollbind' and 'cursorbind' when available */
Karsten Hopp 9faa99
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
+     if (!wp->w_p_diff_saved)
Karsten Hopp 9faa99
+ 	wp->w_p_scb_save = wp->w_p_scb;
Karsten Hopp 9faa99
      wp->w_p_scb = TRUE;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_CURSORBIND
Karsten Hopp 9faa99
+     if (!wp->w_p_diff_saved)
Karsten Hopp 9faa99
+ 	wp->w_p_crb_save = wp->w_p_crb;
Karsten Hopp 9faa99
      wp->w_p_crb = TRUE;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
+     if (!wp->w_p_diff_saved)
Karsten Hopp 9faa99
+ 	wp->w_p_wrap_save = wp->w_p_wrap;
Karsten Hopp 9faa99
      wp->w_p_wrap = FALSE;
Karsten Hopp 9faa99
  # ifdef FEAT_FOLDING
Karsten Hopp 9faa99
      curwin = wp;
Karsten Hopp 9faa99
      curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
+     if (!wp->w_p_diff_saved)
Karsten Hopp 9faa99
+ 	wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
Karsten Hopp 9faa99
      set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
Karsten Hopp 9faa99
  						       OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 9faa99
      curwin = old_curwin;
Karsten Hopp 9faa99
      curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
+     if (!wp->w_p_diff_saved)
Karsten Hopp 9faa99
+     {
Karsten Hopp 9faa99
+ 	wp->w_p_fdc_save = wp->w_p_fdc;
Karsten Hopp 9faa99
+ 	wp->w_p_fen_save = wp->w_p_fen;
Karsten Hopp 9faa99
+ 	wp->w_p_fdl_save = wp->w_p_fdl;
Karsten Hopp 9faa99
+     }
Karsten Hopp 9faa99
      wp->w_p_fdc = diff_foldcolumn;
Karsten Hopp 9faa99
      wp->w_p_fen = TRUE;
Karsten Hopp 9faa99
      wp->w_p_fdl = 0;
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 1164,1169 ****
Karsten Hopp 9faa99
--- 1179,1186 ----
Karsten Hopp 9faa99
      if (vim_strchr(p_sbo, 'h') == NULL)
Karsten Hopp 9faa99
  	do_cmdline_cmd((char_u *)"set sbo+=hor");
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
+     /* Saved the current values, to be restored in ex_diffoff(). */
Karsten Hopp 9faa99
+     wp->w_p_diff_saved = TRUE;
Karsten Hopp 9faa99
  
Karsten Hopp 9faa99
      if (addbuf)
Karsten Hopp 9faa99
  	diff_buf_add(wp->w_buffer);
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 1188,1212 ****
Karsten Hopp 9faa99
      {
Karsten Hopp 9faa99
  	if (wp == curwin || (eap->forceit && wp->w_p_diff))
Karsten Hopp 9faa99
  	{
Karsten Hopp 9faa99
! 	    /* Set 'diff', 'scrollbind' off and 'wrap' on. */
Karsten Hopp 9faa99
  	    wp->w_p_diff = FALSE;
Karsten Hopp 9faa99
! 	    RESET_BINDING(wp);
Karsten Hopp 9faa99
! 	    wp->w_p_wrap = TRUE;
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
  	    curwin = wp;
Karsten Hopp 9faa99
  	    curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
! 	    set_string_option_direct((char_u *)"fdm", -1,
Karsten Hopp 9faa99
  				   (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 9faa99
  	    curwin = old_curwin;
Karsten Hopp 9faa99
  	    curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
! 	    wp->w_p_fdc = 0;
Karsten Hopp 9faa99
! 	    wp->w_p_fen = FALSE;
Karsten Hopp 9faa99
! 	    wp->w_p_fdl = 0;
Karsten Hopp 9faa99
  	    foldUpdateAll(wp);
Karsten Hopp 9faa99
  	    /* make sure topline is not halfway a fold */
Karsten Hopp 9faa99
  	    changed_window_setting_win(wp);
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  	    diff_buf_adjust(wp);
Karsten Hopp 9faa99
  	}
Karsten Hopp 9faa99
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
  	diffwin |= wp->w_p_diff;
Karsten Hopp 9faa99
--- 1205,1252 ----
Karsten Hopp 9faa99
      {
Karsten Hopp 9faa99
  	if (wp == curwin || (eap->forceit && wp->w_p_diff))
Karsten Hopp 9faa99
  	{
Karsten Hopp 9faa99
! 	    /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
Karsten Hopp 9faa99
! 	     * were saved in diff_win_options() restore them. */
Karsten Hopp 9faa99
  	    wp->w_p_diff = FALSE;
Karsten Hopp 9faa99
! 
Karsten Hopp 9faa99
! #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
! 	    if (wp->w_p_scb)
Karsten Hopp 9faa99
! 		wp->w_p_scb = wp->w_p_diff_saved ? wp->w_p_scb_save : FALSE;
Karsten Hopp 9faa99
! #endif
Karsten Hopp 9faa99
! #ifdef FEAT_CURSORBIND
Karsten Hopp 9faa99
! 	    if (wp->w_p_crb)
Karsten Hopp 9faa99
! 		wp->w_p_crb = wp->w_p_diff_saved ? wp->w_p_crb_save : FALSE;
Karsten Hopp 9faa99
! #endif
Karsten Hopp 9faa99
! 	    if (!wp->w_p_wrap)
Karsten Hopp 9faa99
! 		wp->w_p_wrap = wp->w_p_diff_saved ? wp->w_p_wrap_save : TRUE;
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
  	    curwin = wp;
Karsten Hopp 9faa99
  	    curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
! 	    if (wp->w_p_diff_saved)
Karsten Hopp 9faa99
! 	    {
Karsten Hopp 9faa99
! 		free_string_option(wp->w_p_fdm);
Karsten Hopp 9faa99
! 		wp->w_p_fdm = wp->w_p_fdm_save;
Karsten Hopp 9faa99
! 		wp->w_p_fdm_save = empty_option;
Karsten Hopp 9faa99
! 	    }
Karsten Hopp 9faa99
! 	    else
Karsten Hopp 9faa99
! 		set_string_option_direct((char_u *)"fdm", -1,
Karsten Hopp 9faa99
  				   (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
Karsten Hopp 9faa99
  	    curwin = old_curwin;
Karsten Hopp 9faa99
  	    curbuf = curwin->w_buffer;
Karsten Hopp 9faa99
! 	    if (wp->w_p_fdc == diff_foldcolumn)
Karsten Hopp 9faa99
! 		wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0;
Karsten Hopp 9faa99
! 	    if (wp->w_p_fen)
Karsten Hopp 9faa99
! 		wp->w_p_fen = wp->w_p_diff_saved ? wp->w_p_fen_save : FALSE;
Karsten Hopp 9faa99
! 	    if (wp->w_p_fdl == 0 && wp->w_p_diff_saved)
Karsten Hopp 9faa99
! 		wp->w_p_fdl = wp->w_p_fdl_save;
Karsten Hopp 9faa99
  	    foldUpdateAll(wp);
Karsten Hopp 9faa99
  	    /* make sure topline is not halfway a fold */
Karsten Hopp 9faa99
  	    changed_window_setting_win(wp);
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
+ 	    /* Note: 'sbo' is not restored, it's a global option. */
Karsten Hopp 9faa99
  	    diff_buf_adjust(wp);
Karsten Hopp 9faa99
+ 
Karsten Hopp 9faa99
+ 	    wp->w_p_diff_saved = FALSE;
Karsten Hopp 9faa99
  	}
Karsten Hopp 9faa99
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
  	diffwin |= wp->w_p_diff;
Karsten Hopp 9faa99
*** ../vim-7.3.1293/src/structs.h	2013-06-29 14:47:18.000000000 +0200
Karsten Hopp 9faa99
--- src/structs.h	2013-07-03 15:35:59.000000000 +0200
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 141,154 ****
Karsten Hopp 9faa99
--- 141,162 ----
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
      long	wo_fdc;
Karsten Hopp 9faa99
  # define w_p_fdc w_onebuf_opt.wo_fdc	/* 'foldcolumn' */
Karsten Hopp 9faa99
+     int		wo_fdc_save;
Karsten Hopp 9faa99
+ # define w_p_fdc_save w_onebuf_opt.wo_fdc_save	/* 'foldenable' saved for diff mode */
Karsten Hopp 9faa99
      int		wo_fen;
Karsten Hopp 9faa99
  # define w_p_fen w_onebuf_opt.wo_fen	/* 'foldenable' */
Karsten Hopp 9faa99
+     int		wo_fen_save;
Karsten Hopp 9faa99
+ # define w_p_fen_save w_onebuf_opt.wo_fen_save	/* 'foldenable' saved for diff mode */
Karsten Hopp 9faa99
      char_u	*wo_fdi;
Karsten Hopp 9faa99
  # define w_p_fdi w_onebuf_opt.wo_fdi	/* 'foldignore' */
Karsten Hopp 9faa99
      long	wo_fdl;
Karsten Hopp 9faa99
  # define w_p_fdl w_onebuf_opt.wo_fdl	/* 'foldlevel' */
Karsten Hopp 9faa99
+     int		wo_fdl_save;
Karsten Hopp 9faa99
+ # define w_p_fdl_save w_onebuf_opt.wo_fdl_save	/* 'foldlevel' state saved for diff mode */
Karsten Hopp 9faa99
      char_u	*wo_fdm;
Karsten Hopp 9faa99
  # define w_p_fdm w_onebuf_opt.wo_fdm	/* 'foldmethod' */
Karsten Hopp 9faa99
+     char_u	*wo_fdm_save;
Karsten Hopp 9faa99
+ # define w_p_fdm_save w_onebuf_opt.wo_fdm_save	/* 'fdm' saved for diff mode */
Karsten Hopp 9faa99
      long	wo_fml;
Karsten Hopp 9faa99
  # define w_p_fml w_onebuf_opt.wo_fml	/* 'foldminlines' */
Karsten Hopp 9faa99
      long	wo_fdn;
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 213,221 ****
Karsten Hopp 9faa99
--- 221,237 ----
Karsten Hopp 9faa99
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
      int		wo_scb;
Karsten Hopp 9faa99
  # define w_p_scb w_onebuf_opt.wo_scb	/* 'scrollbind' */
Karsten Hopp 9faa99
+     int		wo_diff_saved; /* options were saved for starting diff mode */
Karsten Hopp 9faa99
+ # define w_p_diff_saved w_onebuf_opt.wo_diff_saved
Karsten Hopp 9faa99
+     int		wo_scb_save;	/* 'scrollbind' saved for diff mode*/
Karsten Hopp 9faa99
+ # define w_p_scb_save w_onebuf_opt.wo_scb_save
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
      int		wo_wrap;
Karsten Hopp 9faa99
  #define w_p_wrap w_onebuf_opt.wo_wrap	/* 'wrap' */
Karsten Hopp 9faa99
+ #ifdef FEAT_DIFF
Karsten Hopp 9faa99
+     int		wo_wrap_save;	/* 'wrap' state saved for diff mode*/
Karsten Hopp 9faa99
+ # define w_p_wrap_save w_onebuf_opt.wo_wrap_save
Karsten Hopp 9faa99
+ #endif
Karsten Hopp 9faa99
  #ifdef FEAT_CONCEAL
Karsten Hopp 9faa99
      char_u	*wo_cocu;		/* 'concealcursor' */
Karsten Hopp 9faa99
  # define w_p_cocu w_onebuf_opt.wo_cocu
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 225,230 ****
Karsten Hopp 9faa99
--- 241,248 ----
Karsten Hopp 9faa99
  #ifdef FEAT_CURSORBIND
Karsten Hopp 9faa99
      int		wo_crb;
Karsten Hopp 9faa99
  # define w_p_crb w_onebuf_opt.wo_crb	/* 'cursorbind' */
Karsten Hopp 9faa99
+     int		wo_crb_save;	/* 'cursorbind' state saved for diff mode*/
Karsten Hopp 9faa99
+ # define w_p_crb_save w_onebuf_opt.wo_crb_save
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  
Karsten Hopp 9faa99
  #ifdef FEAT_EVAL
Karsten Hopp 9faa99
*** ../vim-7.3.1293/src/option.c	2013-06-30 17:51:46.000000000 +0200
Karsten Hopp 9faa99
--- src/option.c	2013-07-03 15:35:37.000000000 +0200
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 10118,10131 ****
Karsten Hopp 9faa99
--- 10118,10136 ----
Karsten Hopp 9faa99
      to->wo_stl = vim_strsave(from->wo_stl);
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
      to->wo_wrap = from->wo_wrap;
Karsten Hopp 9faa99
+ #ifdef FEAT_DIFF
Karsten Hopp 9faa99
+     to->wo_wrap_save = from->wo_wrap_save;
Karsten Hopp 9faa99
+ #endif
Karsten Hopp 9faa99
  #ifdef FEAT_LINEBREAK
Karsten Hopp 9faa99
      to->wo_lbr = from->wo_lbr;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_SCROLLBIND
Karsten Hopp 9faa99
      to->wo_scb = from->wo_scb;
Karsten Hopp 9faa99
+     to->wo_scb_save = from->wo_scb_save;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_CURSORBIND
Karsten Hopp 9faa99
      to->wo_crb = from->wo_crb;
Karsten Hopp 9faa99
+     to->wo_crb_save = from->wo_crb_save;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_SPELL
Karsten Hopp 9faa99
      to->wo_spell = from->wo_spell;
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 10137,10142 ****
Karsten Hopp 9faa99
--- 10142,10148 ----
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_DIFF
Karsten Hopp 9faa99
      to->wo_diff = from->wo_diff;
Karsten Hopp 9faa99
+     to->wo_diff_saved = from->wo_diff_saved;
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_CONCEAL
Karsten Hopp 9faa99
      to->wo_cocu = vim_strsave(from->wo_cocu);
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 10144,10154 ****
Karsten Hopp 9faa99
--- 10150,10165 ----
Karsten Hopp 9faa99
  #endif
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
      to->wo_fdc = from->wo_fdc;
Karsten Hopp 9faa99
+     to->wo_fdc_save = from->wo_fdc_save;
Karsten Hopp 9faa99
      to->wo_fen = from->wo_fen;
Karsten Hopp 9faa99
+     to->wo_fen_save = from->wo_fen_save;
Karsten Hopp 9faa99
      to->wo_fdi = vim_strsave(from->wo_fdi);
Karsten Hopp 9faa99
      to->wo_fml = from->wo_fml;
Karsten Hopp 9faa99
      to->wo_fdl = from->wo_fdl;
Karsten Hopp 9faa99
+     to->wo_fdl_save = from->wo_fdl_save;
Karsten Hopp 9faa99
      to->wo_fdm = vim_strsave(from->wo_fdm);
Karsten Hopp 9faa99
+     to->wo_fdm_save = from->wo_diff_saved
Karsten Hopp 9faa99
+ 			      ? vim_strsave(from->wo_fdm_save) : empty_option;
Karsten Hopp 9faa99
      to->wo_fdn = from->wo_fdn;
Karsten Hopp 9faa99
  # ifdef FEAT_EVAL
Karsten Hopp 9faa99
      to->wo_fde = vim_strsave(from->wo_fde);
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 10180,10185 ****
Karsten Hopp 9faa99
--- 10191,10197 ----
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
      check_string_option(&wop->wo_fdi);
Karsten Hopp 9faa99
      check_string_option(&wop->wo_fdm);
Karsten Hopp 9faa99
+     check_string_option(&wop->wo_fdm_save);
Karsten Hopp 9faa99
  # ifdef FEAT_EVAL
Karsten Hopp 9faa99
      check_string_option(&wop->wo_fde);
Karsten Hopp 9faa99
      check_string_option(&wop->wo_fdt);
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 10210,10215 ****
Karsten Hopp 9faa99
--- 10222,10228 ----
Karsten Hopp 9faa99
  #ifdef FEAT_FOLDING
Karsten Hopp 9faa99
      clear_string_option(&wop->wo_fdi);
Karsten Hopp 9faa99
      clear_string_option(&wop->wo_fdm);
Karsten Hopp 9faa99
+     clear_string_option(&wop->wo_fdm_save);
Karsten Hopp 9faa99
  # ifdef FEAT_EVAL
Karsten Hopp 9faa99
      clear_string_option(&wop->wo_fde);
Karsten Hopp 9faa99
      clear_string_option(&wop->wo_fdt);
Karsten Hopp 9faa99
*** ../vim-7.3.1293/src/version.c	2013-07-03 14:19:49.000000000 +0200
Karsten Hopp 9faa99
--- src/version.c	2013-07-03 14:46:59.000000000 +0200
Karsten Hopp 9faa99
***************
Karsten Hopp 9faa99
*** 730,731 ****
Karsten Hopp 9faa99
--- 730,733 ----
Karsten Hopp 9faa99
  {   /* Add new patch number below this line */
Karsten Hopp 9faa99
+ /**/
Karsten Hopp 9faa99
+     1294,
Karsten Hopp 9faa99
  /**/
Karsten Hopp 9faa99
Karsten Hopp 9faa99
-- 
Karsten Hopp 9faa99
Q: What's orange and sounds like a parrot?
Karsten Hopp 9faa99
A: A carrot
Karsten Hopp 9faa99
Karsten Hopp 9faa99
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 9faa99
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 9faa99
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 9faa99
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///