diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-02-02 01:51:56 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-02-11 15:27:56 +0100 |
commit | 61f9a7b0d0308228ce66b7848961152fbb65660f (patch) | |
tree | 00446018c1a9651c56906e77ec4d33dcdda649bd /src/nvim/diff.c | |
parent | ce92e784e14615ba2305105ae2573e3aae49946f (diff) | |
download | rneovim-61f9a7b0d0308228ce66b7848961152fbb65660f.tar.gz rneovim-61f9a7b0d0308228ce66b7848961152fbb65660f.tar.bz2 rneovim-61f9a7b0d0308228ce66b7848961152fbb65660f.zip |
vim-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)
https://github.com/vim/vim/commit/04f62f881c5743d2fdaf7324f6a715381f0d5fcf
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index e55cf7bf7e..0ee1c3815d 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1058,6 +1058,20 @@ void ex_diffthis(exarg_T *eap) 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("diff", (long)value, NULL, OPT_LOCAL); + curbuf_lock--; + curwin = old_curwin; + curbuf = curwin->w_buffer; +} + + /// Set options in window "wp" for diff mode. /// /// @param addbuf Add buffer to diff. @@ -1115,10 +1129,10 @@ void diff_win_options(win_T *wp, int addbuf) do_cmdline_cmd("set sbo+=hor"); } - // Saved the current values, to be restored in ex_diffoff(). - wp->w_p_diff_saved = TRUE; + // 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); @@ -1139,7 +1153,7 @@ void 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) { if (wp->w_p_scb) { |