# HG changeset patch # User Christian Brabandt # Date 1486161004 -3600 # Node ID d9e48fb5142ffcab3a1b29e19a20fc1d119d8f34 # Parent 37ad103a548af1adc693cb1e46204005f7e0ef43 patch 8.0.0300: cannot stop diffing hidden buffers commit https://github.com/vim/vim/commit/25ea0544587dd45088512fec9d7a685e35fea679 Author: Bram Moolenaar 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) diff --git a/src/diff.c b/src/diff.c --- 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) diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -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) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 300, +/**/ 299, /**/ 298,