Patch 8.0.1361
Problem: Some users don't want to diff with hidden buffers.
Solution: Add the "hiddenoff" item to 'diffopt'. (Alisue, closes #2394)
Files: runtime/doc/options.txt, src/buffer.c, src/diff.c,
src/proto/diff.pro, src/testdir/test_diffmode.vim
*** ../vim-8.0.1360/runtime/doc/options.txt 2017-11-26 14:56:11.124133298
+0100
--- runtime/doc/options.txt 2017-12-01 20:30:13.033898380 +0100
***************
*** 2560,2565 ****
--- 2634,2642 ----
vertical Start diff mode with vertical splits (unless
explicitly specified otherwise).
+ hiddenoff Do not use diff mode for a buffer when it
+ becomes hidden.
+
foldcolumn:{n} Set the 'foldcolumn' option to {n} when
starting diff mode. Without this 2 is used.
*** ../vim-8.0.1360/src/buffer.c 2017-10-26 18:21:20.166104258 +0200
--- src/buffer.c 2017-12-01 20:25:59.619252569 +0100
***************
*** 593,598 ****
--- 593,603 ----
if (buf->b_nwindows > 0)
--buf->b_nwindows;
+ #ifdef FEAT_DIFF
+ if (diffopt_hiddenoff() && !unload_buf && buf->b_nwindows == 0)
+ diff_buf_delete(buf); /* Clear 'diff' for hidden buffer. */
+ #endif
+
/* Return when a window is displaying the buffer or when it's not
* unloaded. */
if (buf->b_nwindows > 0 || !unload_buf)
*** ../vim-8.0.1360/src/diff.c 2017-09-04 23:21:02.997152615 +0200
--- src/diff.c 2017-12-01 20:25:59.619252569 +0100
***************
*** 23,28 ****
--- 23,29 ----
#define DIFF_IWHITE 4 /* ignore change in white space */
#define DIFF_HORIZONTAL 8 /* horizontal splits */
#define DIFF_VERTICAL 16 /* vertical splits */
+ #define DIFF_HIDDEN_OFF 32 /* diffoff when hidden */
static int diff_flags = DIFF_FILLER;
#define LBUFLEN 50 /* length of line in diff file */
***************
*** 1924,1929 ****
--- 1925,1935 ----
p += 11;
diff_foldcolumn_new = getdigits(&p);
}
+ else if (STRNCMP(p, "hiddenoff", 9) == 0)
+ {
+ p += 9;
+ diff_flags_new |= DIFF_HIDDEN_OFF;
+ }
if (*p != ',' && *p != NUL)
return FAIL;
if (*p == ',')
***************
*** 1962,1967 ****
--- 1968,1982 ----
}
/*
+ * Return TRUE if 'diffopt' contains "hiddenoff".
+ */
+ int
+ diffopt_hiddenoff(void)
+ {
+ return (diff_flags & DIFF_HIDDEN_OFF) != 0;
+ }
+
+ /*
* Find the difference within a changed line.
* Returns TRUE if the line was added, no other buffer has it.
*/
*** ../vim-8.0.1360/src/proto/diff.pro 2016-10-18 14:50:14.731694041 +0200
--- src/proto/diff.pro 2017-12-01 20:25:59.619252569 +0100
***************
*** 16,21 ****
--- 16,22 ----
void diff_set_topline(win_T *fromwin, win_T *towin);
int diffopt_changed(void);
int diffopt_horizontal(void);
+ int diffopt_hiddenoff(void);
int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp);
int diff_infold(win_T *wp, linenr_T lnum);
void nv_diffgetput(int put, long count);
*** ../vim-8.0.1360/src/testdir/test_diffmode.vim 2017-10-15
22:07:35.207683184 +0200
--- src/testdir/test_diffmode.vim 2017-12-01 20:25:59.619252569 +0100
***************
*** 375,380 ****
--- 375,403 ----
%bwipe
endfunc
+ func Test_diffopt_hiddenoff()
+ set diffopt=filler,foldcolumn:0,hiddenoff
+ e! one
+ call setline(1, ['Two', 'Three'])
+ redraw
+ 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
+ " should not diffing with hidden buffer two while 'hiddenoff' is enabled
+ call assert_equal(normattr, screenattr(1, 1))
+
+ bwipe!
+ bwipe!
+ set hidden& diffopt&
+ endfunc
+
func Test_diffoff_hidden()
set diffopt=filler,foldcolumn:0
e! one
*** ../vim-8.0.1360/src/version.c 2017-11-30 22:07:03.896029952 +0100
--- src/version.c 2017-12-01 20:28:10.574552212 +0100
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1361,
/**/
--
Q: Should I clean my house or work on Vim?
A: Whatever contains more bugs.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.