From aeebed8d611b61ca8e4d469d0f3c0405a9d0f369 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 1 Oct 2016 19:38:34 +0900 Subject: [PATCH 1/3] vim-patch:7.4.2158 Problem: Result of getcompletion('', 'cscope') depends on previous completion. (Christian Brabandt) Solution: Call set_context_in_cscope_cmd(). https://github.com/vim/vim/commit/b650b9878e9f0ac6bb1b61230095ad9ab3850a33 --- src/nvim/eval.c | 5 +++++ src/nvim/testdir/test_cmdline.vim | 16 +++++++++++++--- src/nvim/version.c | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b05b4c4f7e..264472510c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9673,6 +9673,11 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); } + if (xpc.xp_context == EXPAND_CSCOPE) { + set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope); + xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); + } + pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); rettv_list_alloc(rettv); if (pat != NULL) { diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 902ec1c05d..25a6e7200f 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -121,12 +121,22 @@ func Test_getcompletion() let l = getcompletion('dark', 'highlight') call assert_equal([], l) + if has('cscope') + let l = getcompletion('', 'cscope') + let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] + call assert_equal(cmds, l) + " using cmdline completion must not change the result + call feedkeys(":cscope find \\", 'xt') + let l = getcompletion('', 'cscope') + call assert_equal(cmds, l) + let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't'] + let l = getcompletion('find ', 'cscope') + call assert_equal(keys, l) + endif + " For others test if the name is recognized. let names = ['buffer', 'environment', 'file_in_path', \ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user'] - if has('cscope') - call add(names, 'cscope') - endif if has('cmdline_hist') call add(names, 'history') endif diff --git a/src/nvim/version.c b/src/nvim/version.c index 302e78cb6c..c991514482 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -283,7 +283,7 @@ static int included_patches[] = { // 2161, // 2160, // 2159, - // 2158, + 2158, // 2157 NA // 2156 NA // 2155 NA From de802fd4d22e813713bbd6825bfd75c5287a50b4 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 1 Oct 2016 19:41:48 +0900 Subject: [PATCH 2/3] vim-patch:7.4.2162 Problem: Result of getcompletion('', 'sign') depends on previous completion. Solution: Call set_context_in_sign_cmd(). (Dominique Pelle) https://github.com/vim/vim/commit/7522f6982197f83a5c0f6e9af07fb713934f824a --- src/nvim/eval.c | 5 +++++ src/nvim/testdir/test_cmdline.vim | 16 +++++++++++++--- src/nvim/version.c | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 264472510c..82a6c12551 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9678,6 +9678,11 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); } + if (xpc.xp_context == EXPAND_SIGN) { + set_context_in_sign_cmd(&xpc, xpc.xp_pattern); + xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); + } + pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); rettv_list_alloc(rettv); if (pat != NULL) { diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 25a6e7200f..796fbdd45a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -134,6 +134,19 @@ func Test_getcompletion() call assert_equal(keys, l) endif + if has('signs') + sign define Testing linehl=Comment + let l = getcompletion('', 'sign') + let cmds = ['define', 'jump', 'list', 'place', 'undefine', 'unplace'] + call assert_equal(cmds, l) + " using cmdline completion must not change the result + call feedkeys(":sign list \\", 'xt') + let l = getcompletion('', 'sign') + call assert_equal(cmds, l) + let l = getcompletion('list ', 'sign') + call assert_equal(['Testing'], l) + endif + " For others test if the name is recognized. let names = ['buffer', 'environment', 'file_in_path', \ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user'] @@ -146,9 +159,6 @@ func Test_getcompletion() if has('profile') call add(names, 'syntime') endif - if has('signs') - call add(names, 'sign') - endif set tags=Xtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags') diff --git a/src/nvim/version.c b/src/nvim/version.c index c991514482..508d1e8921 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -279,7 +279,7 @@ static int included_patches[] = { // 2165, // 2164, // 2163, - // 2162, + 2162, // 2161, // 2160, // 2159, From db324879d2956a2527851102183723df63039904 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 1 Oct 2016 19:54:59 +0900 Subject: [PATCH 3/3] vim-patch:7.4.2205 Problem: 'wildignore' always applies to getcompletion(). Solution: Add an option to use 'wildignore' or not. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/e9d58a6459687a1228b5aa85bd7b31f8f1e528a8 --- runtime/doc/eval.txt | 9 +++++++-- src/nvim/eval.c | 10 ++++++++++ src/nvim/eval.lua | 2 +- src/nvim/testdir/test_cmdline.vim | 4 ++++ src/nvim/version.c | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index df5713c63d..7deed759b6 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1897,7 +1897,8 @@ getcmdline() String return the current command-line getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type -getcompletion({pat}, {type}) List list of cmdline completion matches +getcompletion({pat}, {type} [, {filtered}]) + List list of cmdline completion matches getcurpos() List position of the cursor getcwd([{winnr} [, {tabnr}]]) String the current working directory getfontname([{name}]) String name of font being used @@ -3651,7 +3652,7 @@ getcmdwintype() *getcmdwintype()* values are the same as |getcmdtype()|. Returns an empty string when not in the command-line window. -getcompletion({pat}, {type}) *getcompletion()* +getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* Return a list of command-line completion matches. {type} specifies what for. The following completion types are supported: @@ -3691,6 +3692,10 @@ getcompletion({pat}, {type}) *getcompletion()* Otherwise only items matching {pat} are returned. See |wildcards| for the use of special characters in {pat}. + If the optional {filtered} flag is set to 1, then 'wildignore' + is applied to filter the results. Otherwise all the matches + are returned. The 'wildignorecase' option always applies. + If there are no matches, an empty list is returned. An invalid value for {type} produces an error. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 82a6c12551..7689ea1a27 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9648,13 +9648,23 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) { char_u *pat; expand_T xpc; + bool filtered = false; int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH | WILD_NO_BEEP; + if (argvars[2].v_type != VAR_UNKNOWN) { + filtered = get_tv_number_chk(&argvars[2], NULL); + } + if (p_wic) { options |= WILD_ICASE; } + // For filtered results, 'wildignore' is used + if (!filtered) { + options |= WILD_KEEP_ALL; + } + ExpandInit(&xpc); xpc.xp_pattern = get_tv_string(&argvars[0]); xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 3c371fc264..984ccebbf8 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -114,7 +114,7 @@ return { getcmdpos={}, getcmdtype={}, getcmdwintype={}, - getcompletion={args=2}, + getcompletion={args={2, 3}}, getcurpos={}, getcwd={args={0,2}}, getfontname={args={0, 1}}, diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 796fbdd45a..bc5a5ca4ec 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -89,6 +89,10 @@ func Test_getcompletion() call assert_true(index(l, 'runtest.vim') >= 0) let l = getcompletion('walk', 'file') call assert_equal([], l) + set wildignore=*.vim + let l = getcompletion('run', 'file', 1) + call assert_true(index(l, 'runtest.vim') < 0) + set wildignore& let l = getcompletion('ha', 'filetype') call assert_true(index(l, 'hamster') >= 0) diff --git a/src/nvim/version.c b/src/nvim/version.c index 508d1e8921..6dc248269a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -236,7 +236,7 @@ static int included_patches[] = { // 2208, // 2207 NA // 2206 NA - // 2205, + 2205, // 2204, // 2203 NA // 2202 NA