@@ -242,43 +242,60 @@ func Test_diffput_two()
242242 bwipe! b
243243endfunc
244244
245+ " :diffput and :diffget completes names of buffers which
246+ " are in diff mode and which are different then current buffer.
247+ " No completion when the current window is not in diff mode.
245248func Test_diffget_diffput_completion ()
246- new Xdiff1 | diffthis
247- new Xdiff2 | diffthis
248- new Xdiff3 | diffthis
249- new Xdiff4
250-
251- " :diffput and :diffget completes names of buffers which
252- " are in diff mode and which are different then current buffer.
253- b Xdiff1
249+ e Xdiff1 | diffthis
250+ botright new Xdiff2
251+ botright new Xdiff3 | split | diffthis
252+ botright new Xdiff4 | diffthis
253+
254+ wincmd t
255+ call assert_equal (' Xdiff1' , bufname (' %' ))
254256 call feedkeys (" :diffput \<C-A>\<C-B> \" \<CR> " , ' tx' )
255- call assert_equal (' "diffput Xdiff2 Xdiff3' , @: )
257+ call assert_equal (' "diffput Xdiff3 Xdiff4 ' , @: )
256258 call feedkeys (" :diffget \<C-A>\<C-B> \" \<CR> " , ' tx' )
257- call assert_equal (' "diffget Xdiff2 Xdiff3' , @: )
258- call assert_equal ([' Xdiff2 ' , ' Xdiff3 ' ], getcompletion (' ' , ' diff_buffer' ))
259+ call assert_equal (' "diffget Xdiff3 Xdiff4 ' , @: )
260+ call assert_equal ([' Xdiff3 ' , ' Xdiff4 ' ], getcompletion (' ' , ' diff_buffer' ))
259261
260- b Xdiff2
262+ " Xdiff2 is not in diff mode, so no completion for :diffput, :diffget
263+ wincmd j
264+ call assert_equal (' Xdiff2' , bufname (' %' ))
261265 call feedkeys (" :diffput \<C-A>\<C-B> \" \<CR> " , ' tx' )
262- call assert_equal (' "diffput Xdiff1 Xdiff3 ' , @: )
266+ call assert_equal (' "diffput ' , @: )
263267 call feedkeys (" :diffget \<C-A>\<C-B> \" \<CR> " , ' tx' )
264- call assert_equal (' "diffget Xdiff1 Xdiff3 ' , @: )
265- call assert_equal ([' Xdiff1 ' , ' Xdiff3 ' ], getcompletion (' ' , ' diff_buffer' ))
268+ call assert_equal (' "diffget ' , @: )
269+ call assert_equal ([], getcompletion (' ' , ' diff_buffer' ))
266270
267- b Xdiff3
271+ " Xdiff3 is split in 2 windows, only the top one is in diff mode.
272+ " So completion of :diffput :diffget only happens in the top window.
273+ wincmd j
274+ call assert_equal (' Xdiff3' , bufname (' %' ))
275+ call assert_equal (1 , &diff )
268276 call feedkeys (" :diffput \<C-A>\<C-B> \" \<CR> " , ' tx' )
269- call assert_equal (' "diffput Xdiff1 Xdiff2 ' , @: )
277+ call assert_equal (' "diffput Xdiff1 Xdiff4 ' , @: )
270278 call feedkeys (" :diffget \<C-A>\<C-B> \" \<CR> " , ' tx' )
271- call assert_equal (' "diffget Xdiff1 Xdiff2 ' , @: )
272- call assert_equal ([' Xdiff1' , ' Xdiff2 ' ], getcompletion (' ' , ' diff_buffer' ))
279+ call assert_equal (' "diffget Xdiff1 Xdiff4 ' , @: )
280+ call assert_equal ([' Xdiff1' , ' Xdiff4 ' ], getcompletion (' ' , ' diff_buffer' ))
273281
274- " No completion when in Xdiff4, it's not in diff mode.
275- b Xdiff4
282+ wincmd j
283+ call assert_equal (' Xdiff3' , bufname (' %' ))
284+ call assert_equal (0 , &diff )
276285 call feedkeys (" :diffput \<C-A>\<C-B> \" \<CR> " , ' tx' )
277286 call assert_equal (' "diffput ' , @: )
278287 call feedkeys (" :diffget \<C-A>\<C-B> \" \<CR> " , ' tx' )
279288 call assert_equal (' "diffget ' , @: )
280289 call assert_equal ([], getcompletion (' ' , ' diff_buffer' ))
281290
291+ wincmd j
292+ call assert_equal (' Xdiff4' , bufname (' %' ))
293+ call feedkeys (" :diffput \<C-A>\<C-B> \" \<CR> " , ' tx' )
294+ call assert_equal (' "diffput Xdiff1 Xdiff3' , @: )
295+ call feedkeys (" :diffget \<C-A>\<C-B> \" \<CR> " , ' tx' )
296+ call assert_equal (' "diffget Xdiff1 Xdiff3' , @: )
297+ call assert_equal ([' Xdiff1' , ' Xdiff3' ], getcompletion (' ' , ' diff_buffer' ))
298+
282299 % bwipe
283300endfunc
284301
0 commit comments