summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-27 17:20:55 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-27 17:20:55 +0100
commit297610ba4b110c918ffe60c45eb4a1d6ea2daae5 (patch)
treeee04b17c7069ce83dd0f7f19ec30d1a9d58b7298
parent5c463a28fff1d82222d49bc7960da9e0c866b060 (diff)
downloadvim-git-297610ba4b110c918ffe60c45eb4a1d6ea2daae5.tar.gz
patch 8.2.0049: command line completion not fully testedv8.2.0049
Problem: Command line completion not fully tested. Solution: Add more test cases. Make help sorting stable. (Dominique Pelle, closes #5402)
-rw-r--r--src/ex_cmds.c10
-rw-r--r--src/testdir/test_cd.vim15
-rw-r--r--src/testdir/test_cmdline.vim17
-rw-r--r--src/testdir/test_help.vim5
-rw-r--r--src/testdir/test_menu.vim4
-rw-r--r--src/testdir/test_options.vim7
-rw-r--r--src/testdir/test_syntax.vim5
-rw-r--r--src/version.c2
8 files changed, 64 insertions, 1 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 491049194..c8a93bc0a 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5341,10 +5341,18 @@ help_compare(const void *s1, const void *s2)
{
char *p1;
char *p2;
+ int cmp;
p1 = *(char **)s1 + strlen(*(char **)s1) + 1;
p2 = *(char **)s2 + strlen(*(char **)s2) + 1;
- return strcmp(p1, p2);
+
+ // Compare by help heuristic number first.
+ cmp = strcmp(p1, p2);
+ if (cmp != 0)
+ return cmp;
+
+ // Compare by strings as tie-breaker when same heuristic number.
+ return strcmp(*(char **)s1, *(char **)s2);
}
/*
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim
index bdb26cddc..05d3877c7 100644
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -106,3 +106,18 @@ func Test_chdir_func()
call chdir(topdir)
call delete('Xdir', 'rf')
endfunc
+
+func Test_cd_completion()
+ call mkdir('XComplDir1', 'p')
+ call mkdir('XComplDir2', 'p')
+ call writefile([], 'XComplFile')
+
+ for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir']
+ call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:)
+ endfor
+
+ call delete('XComplDir1', 'd')
+ call delete('XComplDir2', 'd')
+ call delete('XComplFile')
+endfunc
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 837ef63dd..38b5826e6 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -553,6 +553,14 @@ func Test_cmdline_complete_user_names()
endif
endfunc
+func Test_cmdline_complete_bang()
+ if executable('whoami')
+ return
+ endif
+ call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^".*\<whoami\>', @:)
+endfunc
+
funct Test_cmdline_complete_languages()
let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '')
@@ -575,6 +583,15 @@ funct Test_cmdline_complete_languages()
endif
endfunc
+func Test_cmdline_complete_env_variable()
+ let $X_VIM_TEST_COMPLETE_ENV = 'foo'
+
+ call feedkeys(":edit $X_VIM_TEST_COMPLETE_E\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('"edit $X_VIM_TEST_COMPLETE_ENV', @:)
+
+ unlet $X_VIM_TEST_COMPLETE_ENV
+endfunc
+
func Test_cmdline_write_alternatefile()
new
call setline('.', ['one', 'two'])
diff --git a/src/testdir/test_help.vim b/src/testdir/test_help.vim
index 5dd937a93..4f46a44c9 100644
--- a/src/testdir/test_help.vim
+++ b/src/testdir/test_help.vim
@@ -55,3 +55,8 @@ func Test_help_local_additions()
call delete('Xruntime', 'rf')
let &rtp = rtp_save
endfunc
+
+func Test_help_completion()
+ call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:)
+endfunc
diff --git a/src/testdir/test_menu.vim b/src/testdir/test_menu.vim
index 0d6b78ef7..04d45d611 100644
--- a/src/testdir/test_menu.vim
+++ b/src/testdir/test_menu.vim
@@ -45,6 +45,10 @@ func Test_menu_commands()
imenu 2 Test.FooBar :let g:did_menu = 'insert'<CR>
cmenu 2 Test.FooBar :let g:did_menu = 'cmdline'<CR>
emenu n Test.FooBar
+
+ call feedkeys(":menu Test.FooB\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"menu Test.FooBar', @:)
+
call assert_equal('normal', g:did_menu)
emenu v Test.FooBar
call assert_equal('visual', g:did_menu)
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 048356ae7..636a24d6e 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -201,6 +201,12 @@ func Test_set_completion()
call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
+ call feedkeys(":setlocal di\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"setlocal dictionary diff diffexpr diffopt digraph directory display', @:)
+
+ call feedkeys(":setglobal di\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:)
+
" Expand boolan options. When doing :set no<Tab>
" vim displays the options names without "no" but completion uses "no...".
call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
@@ -239,6 +245,7 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
+
set tags&
endfunc
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index 21ee8dc62..389294ec7 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -180,6 +180,11 @@ func Test_syntax_completion()
call assert_match('^"syn match Boolean Character ', @:)
endfunc
+func Test_echohl_completion()
+ call feedkeys(":echohl no\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"echohl NonText Normal none', @:)
+endfunc
+
func Test_syntax_arg_skipped()
syn clear
syntax case ignore
diff --git a/src/version.c b/src/version.c
index 0fc35dc83..85c8462df 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 49,
+/**/
48,
/**/
47,