]> granicus.if.org Git - vim/commitdiff
patch 8.0.0300: cannot stop diffing hidden buffers v8.0.0300
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Feb 2017 22:16:28 +0000 (23:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Feb 2017 22:16:28 +0000 (23:16 +0100)
Problem:    Cannot stop diffing hidden buffers. (Daniel Hahler)
Solution:   When using :diffoff! make the whole list if diffed buffers empty.
            (closes #736)

src/diff.c
src/testdir/test_diffmode.vim
src/version.c

index a4a2acb95f7f48fbce529165273cd5a4854b2da5..8d7421dd73faa574edb3f8a2ef441a6af25f4f63 100644 (file)
@@ -138,6 +138,23 @@ diff_buf_add(buf_T *buf)
     EMSGN(_("E96: Cannot diff more than %ld buffers"), DB_COUNT);
 }
 
+/*
+ * 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)
index f40e06ff3358b651604738a1357c3b2a0f96cda9..8ee82bd538d11d19e2b8f73ff2c75de9da804016 100644 (file)
@@ -212,6 +212,7 @@ func Test_diffoff()
   call setline(1, ['One', '', 'Two', 'Three'])
   diffthis
   redraw
+  call assert_notequal(normattr, screenattr(1, 1))
   diffoff!
   redraw
   call assert_equal(normattr, screenattr(1, 1))
@@ -219,6 +220,42 @@ func Test_diffoff()
   bwipe!
 endfunc
 
+func Test_diffoff_hidden()
+  set diffopt=filler,foldcolumn:0
+  e! one
+  call setline(1, ['Two', 'Three'])
+  let normattr = screenattr(1, 1)
+  diffthis
+  botright vert new two
+  call setline(1, ['One', 'Four'])
+  diffthis
+  redraw
+  call assert_notequal(normattr, screenattr(1, 1))
+  set hidden
+  close
+  redraw
+  " diffing with hidden buffer two
+  call assert_notequal(normattr, screenattr(1, 1))
+  diffoff
+  redraw
+  call assert_equal(normattr, screenattr(1, 1))
+  diffthis
+  redraw
+  " still diffing with hidden buffer two
+  call assert_notequal(normattr, screenattr(1, 1))
+  diffoff!
+  redraw
+  call assert_equal(normattr, screenattr(1, 1))
+  diffthis
+  redraw
+  " no longer diffing with hidden buffer two
+  call assert_equal(normattr, screenattr(1, 1))
+
+  bwipe!
+  bwipe!
+  set hidden& diffopt&
+endfunc
+
 func Test_setting_cursor()
   new Xtest1
   put =range(1,90)
index fa51e5694440bfbaf7dd6adbfb894a7724eb3de7..da53eb3cfc7a72ad537b8fcdd462b53efe356846 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    300,
 /**/
     299,
 /**/