diff src/diff.c @ 10821:d9e48fb5142f v8.0.0300

patch 8.0.0300: cannot stop diffing hidden buffers commit https://github.com/vim/vim/commit/25ea0544587dd45088512fec9d7a685e35fea679 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 3 23:16:28 2017 +0100 patch 8.0.0300: cannot stop diffing hidden buffers Problem: Cannot stop diffing hidden buffers. (Daniel Hahler) Solution: When using :diffoff! make the whole list if diffed buffers empty. (closes #736)
author Christian Brabandt <cb@256bit.org>
date Fri, 03 Feb 2017 23:30:04 +0100
parents d0b74b18e4b5
children d2178a6cc9f3
line wrap: on
line diff
--- a/src/diff.c
+++ b/src/diff.c
@@ -139,6 +139,23 @@ diff_buf_add(buf_T *buf)
 }
 
 /*
+ * Remove all buffers to make diffs for.
+ */
+    static void
+diff_buf_clear(void)
+{
+    int		i;
+
+    for (i = 0; i < DB_COUNT; ++i)
+	if (curtab->tp_diffbuf[i] != NULL)
+	{
+	    curtab->tp_diffbuf[i] = NULL;
+	    curtab->tp_diff_invalid = TRUE;
+	    diff_redraw(TRUE);
+	}
+}
+
+/*
  * Find buffer "buf" in the list of diff buffers for the current tab page.
  * Return its index or DB_COUNT if not found.
  */
@@ -1257,6 +1274,10 @@ ex_diffoff(exarg_T *eap)
 #endif
     }
 
+    /* Also remove hidden buffers from the list. */
+    if (eap->forceit)
+	diff_buf_clear();
+
 #ifdef FEAT_SCROLLBIND
     /* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
     if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)