aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index c2ab57a59b..0ee1c3815d 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -855,7 +855,7 @@ void ex_diffpatch(exarg_T *eap)
{
char_u *buf = NULL;
win_T *old_curwin = curwin;
- char_u *newname = NULL; // name of patched file buffer
+ char_u *newname = NULL; // name of patched file buffer
char_u *esc_name = NULL;
#ifdef UNIX
@@ -886,9 +886,9 @@ void ex_diffpatch(exarg_T *eap)
esc_name = vim_strsave_shellescape(
#ifdef UNIX
- fullname != NULL ? fullname :
+ fullname != NULL ? fullname :
#endif
- eap->arg, true, true);
+ eap->arg, true, true);
if (esc_name == NULL) {
goto theend;
}
@@ -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) {