Patch 8.2.0054
Problem: :diffget and :diffput don't have good completion.
Solution: Add proper completion. (Dominique Pelle, closes #5409)
Files: runtime/doc/eval.txt, src/buffer.c, src/cmdexpand.c,
src/testdir/test_diffmode.vim, src/usercmd.c, src/vim.h
*** ../vim-8.2.0053/runtime/doc/eval.txt 2019-12-27 13:49:19.988946876
+0100
--- runtime/doc/eval.txt 2019-12-29 13:50:53.886258074 +0100
***************
*** 5059,5064 ****
--- 5058,5064 ----
command Ex command (and arguments)
compiler compilers
cscope |:cscope| suboptions
+ diff_buffer |:diffget| and |:diffput| completion
dir directory names
environment environment variable names
event autocommand events
*** ../vim-8.2.0053/src/buffer.c 2019-12-23 22:59:14.260820709 +0100
--- src/buffer.c 2019-12-29 13:50:53.886258074 +0100
***************
*** 2702,2707 ****
--- 2702,2716 ----
{
if (!buf->b_p_bl) // skip unlisted buffers
continue;
+ #ifdef FEAT_DIFF
+ 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
+
p = buflist_match(®match, buf, p_wic);
if (p != NULL)
{
*** ../vim-8.2.0053/src/cmdexpand.c 2019-11-26 16:38:29.000000000 +0100
--- src/cmdexpand.c 2019-12-29 13:50:53.886258074 +0100
***************
*** 1582,1588 ****
xp->xp_context = EXPAND_BUFFERS;
xp->xp_pattern = arg;
break;
!
case CMD_USER:
case CMD_USER_BUF:
if (compl != EXPAND_NOTHING)
--- 1582,1596 ----
xp->xp_context = EXPAND_BUFFERS;
xp->xp_pattern = arg;
break;
! #ifdef FEAT_DIFF
! case CMD_diffget:
! case CMD_diffput:
! // If current buffer is in diff mode, complete buffer names
! // which are in diff mode, and different than current buffer.
! xp->xp_context = EXPAND_DIFF_BUFFERS;
! xp->xp_pattern = arg;
! break;
! #endif
case CMD_USER:
case CMD_USER_BUF:
if (compl != EXPAND_NOTHING)
***************
*** 2069,2074 ****
--- 2077,2086 ----
return ExpandOldSetting(num_file, file);
if (xp->xp_context == EXPAND_BUFFERS)
return ExpandBufnames(pat, num_file, file, options);
+ #ifdef FEAT_DIFF
+ if (xp->xp_context == EXPAND_DIFF_BUFFERS)
+ return ExpandBufnames(pat, num_file, file, options | BUF_DIFF_FILTER);
+ #endif
if (xp->xp_context == EXPAND_TAGS
|| xp->xp_context == EXPAND_TAGS_LISTFILES)
return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
*** ../vim-8.2.0053/src/testdir/test_diffmode.vim 2019-11-16
13:21:05.000000000 +0100
--- src/testdir/test_diffmode.vim 2019-12-29 13:50:53.886258074 +0100
***************
*** 242,247 ****
--- 242,287 ----
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
+
func Test_dp_do_buffer()
e! one
let bn1=bufnr('%')
*** ../vim-8.2.0053/src/usercmd.c 2019-12-05 21:41:34.000000000 +0100
--- src/usercmd.c 2019-12-29 13:50:53.886258074 +0100
***************
*** 57,62 ****
--- 57,63 ----
{EXPAND_USER_DEFINED, "custom"},
{EXPAND_USER_LIST, "customlist"},
#endif
+ {EXPAND_DIFF_BUFFERS, "diff_buffer"},
{EXPAND_DIRECTORIES, "dir"},
{EXPAND_ENV_VARS, "environment"},
{EXPAND_EVENTS, "event"},
*** ../vim-8.2.0053/src/vim.h 2019-12-14 16:18:11.582458385 +0100
--- src/vim.h 2019-12-29 13:50:53.886258074 +0100
***************
*** 801,806 ****
--- 801,807 ----
#define EXPAND_MESSAGES 46
#define EXPAND_MAPCLEAR 47
#define EXPAND_ARGLIST 48
+ #define EXPAND_DIFF_BUFFERS 49
// Values for exmode_active (0 is no exmode)
#define EXMODE_NORMAL 1
***************
*** 829,834 ****
--- 830,836 ----
#define WILD_IGNORE_COMPLETESLASH 0x400
#define WILD_NOERROR 0x800 // sets EW_NOERROR
#define WILD_BUFLASTUSED 0x1000
+ #define BUF_DIFF_FILTER 0x2000
// Flags for expand_wildcards()
#define EW_DIR 0x01 // include directory names
*** ../vim-8.2.0053/src/version.c 2019-12-29 13:43:50.324021457 +0100
--- src/version.c 2019-12-29 13:52:06.057957270 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 54,
/**/
--
DENNIS: Listen -- strange women lying in ponds distributing swords is no
basis for a system of government. Supreme executive power derives
from a mandate from the masses, not from some farcical aquatic
ceremony.
The Quest for the Holy Grail (Monty Python)
/// 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201912291257.xBTCvTfa009306%40masaka.moolenaar.net.