summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-28 22:53:37 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-28 22:53:37 +0200
commitb56195ed00a9a79aa6217cddbeedbc8cc7a5b6d8 (patch)
tree341dc463600cbb27377711dc00ddd0fda5fda44d
parent471a8975690af01a1244b28d5b5f978ca623028f (diff)
downloadvim-git-7.4.2112.tar.gz
patch 7.4.2112v7.4.2112
Problem: getcompletion(.., 'dir') returns a match with trailing "*" when there are no matches. (Chdiza) Solution: Return an empty list when there are no matches. Add a trailing slash to directories. (Yegappan Lakshmanan) Add tests for no matches. (closes #947)
-rw-r--r--src/evalfunc.c6
-rw-r--r--src/testdir/test_cmdline.vim34
-rw-r--r--src/version.c2
3 files changed, 37 insertions, 5 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ae17038cc..53783af74 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4164,8 +4164,8 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
{
char_u *pat;
expand_T xpc;
- int options = WILD_KEEP_ALL | WILD_SILENT | WILD_USE_NL
- | WILD_LIST_NOTFOUND | WILD_NO_BEEP;
+ int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
+ | WILD_NO_BEEP;
if (p_wic)
options |= WILD_ICASE;
@@ -4194,7 +4194,7 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL))
{
- int i;
+ int i;
ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP);
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 0ddbcec26..c6d416f1e 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -47,53 +47,83 @@ func Test_getcompletion()
let l = getcompletion('v:n', 'var')
call assert_true(index(l, 'v:null') >= 0)
+ let l = getcompletion('v:notexists', 'var')
+ call assert_equal([], l)
let l = getcompletion('', 'augroup')
call assert_true(index(l, 'END') >= 0)
+ let l = getcompletion('blahblah', 'augroup')
+ call assert_equal([], l)
let l = getcompletion('', 'behave')
call assert_true(index(l, 'mswin') >= 0)
+ let l = getcompletion('not', 'behave')
+ call assert_equal([], l)
let l = getcompletion('', 'color')
call assert_true(index(l, 'default') >= 0)
+ let l = getcompletion('dirty', 'color')
+ call assert_equal([], l)
let l = getcompletion('', 'command')
call assert_true(index(l, 'sleep') >= 0)
+ let l = getcompletion('awake', 'command')
+ call assert_equal([], l)
let l = getcompletion('', 'dir')
- call assert_true(index(l, 'samples') >= 0)
+ call assert_true(index(l, 'samples/') >= 0)
+ let l = getcompletion('NoMatch', 'dir')
+ call assert_equal([], l)
let l = getcompletion('exe', 'expression')
call assert_true(index(l, 'executable(') >= 0)
+ let l = getcompletion('kill', 'expression')
+ call assert_equal([], l)
let l = getcompletion('tag', 'function')
call assert_true(index(l, 'taglist(') >= 0)
+ let l = getcompletion('paint', 'function')
+ call assert_equal([], l)
let Flambda = {-> 'hello'}
let l = getcompletion('', 'function')
let l = filter(l, {i, v -> v =~ 'lambda'})
- call assert_equal(0, len(l))
+ call assert_equal([], l)
let l = getcompletion('run', 'file')
call assert_true(index(l, 'runtest.vim') >= 0)
+ let l = getcompletion('walk', 'file')
+ call assert_equal([], l)
let l = getcompletion('ha', 'filetype')
call assert_true(index(l, 'hamster') >= 0)
+ let l = getcompletion('horse', 'filetype')
+ call assert_equal([], l)
let l = getcompletion('z', 'syntax')
call assert_true(index(l, 'zimbu') >= 0)
+ let l = getcompletion('emacs', 'syntax')
+ call assert_equal([], l)
let l = getcompletion('jikes', 'compiler')
call assert_true(index(l, 'jikes') >= 0)
+ let l = getcompletion('break', 'compiler')
+ call assert_equal([], l)
let l = getcompletion('last', 'help')
call assert_true(index(l, ':tablast') >= 0)
+ let l = getcompletion('giveup', 'help')
+ call assert_equal([], l)
let l = getcompletion('time', 'option')
call assert_true(index(l, 'timeoutlen') >= 0)
+ let l = getcompletion('space', 'option')
+ call assert_equal([], l)
let l = getcompletion('er', 'highlight')
call assert_true(index(l, 'ErrorMsg') >= 0)
+ let l = getcompletion('dark', 'highlight')
+ call assert_equal([], l)
" For others test if the name is recognized.
let names = ['buffer', 'environment', 'file_in_path',
diff --git a/src/version.c b/src/version.c
index d5912dc23..53597e9de 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2112,
+/**/
2111,
/**/
2110,