Patch 8.2.0064

7 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 30, 2019, 3:59:55 PM12/30/19
to vim...@googlegroups.com

Patch 8.2.0064
Problem: Diffmode completion doesn't use per-window setting.
Solution: Check if a window is in diff mode. (Dominique Pell, closes #5419)
Files: src/buffer.c, src/testdir/test_diffmode.vim


*** ../vim-8.2.0063/src/buffer.c 2019-12-29 23:04:20.290639897 +0100
--- src/buffer.c 2019-12-30 21:45:49.905248225 +0100
***************
*** 2661,2666 ****
--- 2661,2671 ----
*num_file = 0; // return values in case of FAIL
*file = NULL;

+ #ifdef FEAT_DIFF
+ if ((options & BUF_DIFF_FILTER) && !curwin->w_p_diff)
+ return FAIL;
+ #endif
+
// Make a copy of "pat" and change "^" to "\(^\|[\/]\)".
if (*pat == '^')
{
***************
*** 2706,2713 ****
if (options & BUF_DIFF_FILTER)
// Skip buffers not suitable for
// :diffget or :diffput completion.
! if (buf == curbuf
! || !diff_mode_buf(curbuf) || !diff_mode_buf(buf))
continue;
#endif

--- 2711,2717 ----
if (options & BUF_DIFF_FILTER)
// Skip buffers not suitable for
// :diffget or :diffput completion.
! if (buf == curbuf || !diff_mode_buf(buf))
continue;
#endif

*** ../vim-8.2.0063/src/testdir/test_diffmode.vim 2019-12-29 13:56:28.692861883 +0100
--- src/testdir/test_diffmode.vim 2019-12-30 21:45:49.905248225 +0100
***************
*** 242,284 ****
bwipe! b
endfunc

func Test_diffget_diffput_completion()
! new Xdiff1 | diffthis
! new Xdiff2 | diffthis
! new Xdiff3 | diffthis
! new Xdiff4
!
! " :diffput and :diffget completes names of buffers which
! " are in diff mode and which are different then current buffer.
! b Xdiff1
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput Xdiff2 Xdiff3', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget Xdiff2 Xdiff3', @:)
! call assert_equal(['Xdiff2', 'Xdiff3'], getcompletion('', 'diff_buffer'))

! b Xdiff2
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput Xdiff1 Xdiff3', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget Xdiff1 Xdiff3', @:)
! call assert_equal(['Xdiff1', 'Xdiff3'], getcompletion('', 'diff_buffer'))

! b Xdiff3
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput Xdiff1 Xdiff2', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget Xdiff1 Xdiff2', @:)
! call assert_equal(['Xdiff1', 'Xdiff2'], getcompletion('', 'diff_buffer'))

! " No completion when in Xdiff4, it's not in diff mode.
! b Xdiff4
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"diffput ', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"diffget ', @:)
call assert_equal([], getcompletion('', 'diff_buffer'))

%bwipe
endfunc

--- 242,301 ----
bwipe! b
endfunc

+ " :diffput and :diffget completes names of buffers which
+ " are in diff mode and which are different then current buffer.
+ " No completion when the current window is not in diff mode.
func Test_diffget_diffput_completion()
! e Xdiff1 | diffthis
! botright new Xdiff2
! botright new Xdiff3 | split | diffthis
! botright new Xdiff4 | diffthis
!
! wincmd t
! call assert_equal('Xdiff1', bufname('%'))
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput Xdiff3 Xdiff4', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget Xdiff3 Xdiff4', @:)
! call assert_equal(['Xdiff3', 'Xdiff4'], getcompletion('', 'diff_buffer'))

! " Xdiff2 is not in diff mode, so no completion for :diffput, :diffget
! wincmd j
! call assert_equal('Xdiff2', bufname('%'))
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput ', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget ', @:)
! call assert_equal([], getcompletion('', 'diff_buffer'))

! " Xdiff3 is split in 2 windows, only the top one is in diff mode.
! " So completion of :diffput :diffget only happens in the top window.
! wincmd j
! call assert_equal('Xdiff3', bufname('%'))
! call assert_equal(1, &diff)
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffput Xdiff1 Xdiff4', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"diffget Xdiff1 Xdiff4', @:)
! call assert_equal(['Xdiff1', 'Xdiff4'], getcompletion('', 'diff_buffer'))

! wincmd j
! call assert_equal('Xdiff3', bufname('%'))
! call assert_equal(0, &diff)
call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"diffput ', @:)
call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"diffget ', @:)
call assert_equal([], getcompletion('', 'diff_buffer'))

+ wincmd j
+ call assert_equal('Xdiff4', bufname('%'))
+ call feedkeys(":diffput \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"diffput Xdiff1 Xdiff3', @:)
+ call feedkeys(":diffget \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"diffget Xdiff1 Xdiff3', @:)
+ call assert_equal(['Xdiff1', 'Xdiff3'], getcompletion('', 'diff_buffer'))
+
%bwipe
endfunc

*** ../vim-8.2.0063/src/version.c 2019-12-30 20:42:35.377103372 +0100
--- src/version.c 2019-12-30 21:58:21.947889499 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 64,
/**/

--
FATHER: You only killed the bride's father - that's all -
LAUNCELOT: Oh dear, I didn't really mean to...
FATHER: Didn't mean to? You put your sword right through his head!
LAUNCELOT: Gosh - Is he all right?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages