summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-10 21:00:27 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-10 21:00:27 +0100
commitc8234779790dd873acb88331c50988adf94cc383 (patch)
treed3e58b31d9e4593956cd028e4468051ce3d79dfc /src/diff.c
parent5c6b6187ac51a4d8545e823c1be6cdf70cac8a57 (diff)
patch 8.1.2289: after :diffsplit closing the window does not disable diffv8.1.2289
Problem: After :diffsplit closing the window does not disable diff. Solution: Add "closeoff" to 'diffopt' and add it to the default.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c
index 120a544965..b16f7b6f3e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -35,8 +35,9 @@ static int diff_need_update = FALSE; // ex_diffupdate needs to be called
#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.
*/