diff src/diff.c @ 18590:41484f342f80 v8.1.2289

patch 8.1.2289: after :diffsplit closing the window does not disable diff Commit: https://github.com/vim/vim/commit/c8234779790dd873acb88331c50988adf94cc383 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 10 21:00:27 2019 +0100 patch 8.1.2289: after :diffsplit closing the window does not disable diff Problem: After :diffsplit closing the window does not disable diff. Solution: Add "closeoff" to 'diffopt' and add it to the default.
author Bram Moolenaar <Bram@vim.org>
date Sun, 10 Nov 2019 21:15:04 +0100
parents 9e6d5a4abb1c
children 788d76db02ac
line wrap: on
line diff
--- a/src/diff.c
+++ b/src/diff.c
@@ -35,8 +35,9 @@ static int diff_need_update = FALSE; // 
 #define DIFF_VERTICAL	0x080	// vertical splits
 #define DIFF_HIDDEN_OFF	0x100	// diffoff when hidden
 #define DIFF_INTERNAL	0x200	// use internal xdiff algorithm
+#define DIFF_CLOSE_OFF	0x400	// diffoff when closing window
 #define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
-static int	diff_flags = DIFF_INTERNAL | DIFF_FILLER;
+static int	diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
 
 static long diff_algorithm = 0;
 
@@ -1545,6 +1546,14 @@ ex_diffoff(exarg_T *eap)
     if (eap->forceit)
 	diff_buf_clear();
 
+    if (!diffwin)
+    {
+	diff_need_update = FALSE;
+	curtab->tp_diff_invalid = FALSE;
+	curtab->tp_diff_update = FALSE;
+	diff_clear(curtab);
+    }
+
     /* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
     if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)
 	do_cmdline_cmd((char_u *)"set sbo-=hor");
@@ -2222,6 +2231,11 @@ diffopt_changed(void)
 	    p += 9;
 	    diff_flags_new |= DIFF_HIDDEN_OFF;
 	}
+	else if (STRNCMP(p, "closeoff", 8) == 0)
+	{
+	    p += 8;
+	    diff_flags_new |= DIFF_CLOSE_OFF;
+	}
 	else if (STRNCMP(p, "indent-heuristic", 16) == 0)
 	{
 	    p += 16;
@@ -2310,6 +2324,15 @@ diffopt_hiddenoff(void)
 }
 
 /*
+ * Return TRUE if 'diffopt' contains "closeoff".
+ */
+    int
+diffopt_closeoff(void)
+{
+    return (diff_flags & DIFF_CLOSE_OFF) != 0;
+}
+
+/*
  * Find the difference within a changed line.
  * Returns TRUE if the line was added, no other buffer has it.
  */