diff src/diff.c @ 11707:1395a3b6978d v8.0.0736

patch 8.0.0736: OptionSet not triggered when entering diff mode commit https://github.com/vim/vim/commit/04f62f881c5743d2fdaf7324f6a715381f0d5fcf Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 19 18:18:39 2017 +0200 patch 8.0.0736: OptionSet not triggered when entering diff mode Problem: The OptionSet autocommand event is not triggered when entering diff mode. Solution: use set_option_value() instead of setting the option directly. Change the tests from old to new style. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Wed, 19 Jul 2017 18:30:03 +0200
parents eba1a8c6e21d
children 40ee9f3d265f
line wrap: on
line diff
--- a/src/diff.c
+++ b/src/diff.c
@@ -1137,6 +1137,20 @@ ex_diffthis(exarg_T *eap UNUSED)
     diff_win_options(curwin, TRUE);
 }
 
+    static void
+set_diff_option(win_T *wp, int value)
+{
+    win_T *old_curwin = curwin;
+
+    curwin = wp;
+    curbuf = curwin->w_buffer;
+    ++curbuf_lock;
+    set_option_value((char_u *)"diff", (long)value, NULL, OPT_LOCAL);
+    --curbuf_lock;
+    curwin = old_curwin;
+    curbuf = curwin->w_buffer;
+}
+
 /*
  * Set options in window "wp" for diff mode.
  */
@@ -1198,10 +1212,10 @@ diff_win_options(
     if (vim_strchr(p_sbo, 'h') == NULL)
 	do_cmdline_cmd((char_u *)"set sbo+=hor");
 #endif
-    /* Saved the current values, to be restored in ex_diffoff(). */
+    /* Save the current values, to be restored in ex_diffoff(). */
     wp->w_p_diff_saved = TRUE;
 
-    wp->w_p_diff = TRUE;
+    set_diff_option(wp, TRUE);
 
     if (addbuf)
 	diff_buf_add(wp->w_buffer);
@@ -1227,7 +1241,7 @@ ex_diffoff(exarg_T *eap)
 	    /* Set 'diff' off. If option values were saved in
 	     * diff_win_options(), restore the ones whose settings seem to have
 	     * been left over from diff mode.  */
-	    wp->w_p_diff = FALSE;
+	    set_diff_option(wp, FALSE);
 
 	    if (wp->w_p_diff_saved)
 	    {