summaryrefslogtreecommitdiff
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-19 18:18:39 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-19 18:18:39 +0200
commit04f62f881c5743d2fdaf7324f6a715381f0d5fcf (patch)
treef2db897422696463e859521127d9a6878f354efe /src/diff.c
parenta8788f4d0b991f466b607c2c5bc6fd600bc78a97 (diff)
downloadvim-git-04f62f881c5743d2fdaf7324f6a715381f0d5fcf.tar.gz
patch 8.0.0736: OptionSet not triggered when entering diff modev8.0.0736
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)
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/diff.c b/src/diff.c
index dfc968f83..dac39c21e 100644
--- 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)
{