aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-01 10:54:41 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-01 11:02:55 +0800
commit300490f2e8e94ee471685cd9809964c10ebdc1ed (patch)
treed5e13bc8ca3d21531a98923ce327d380b7d19394
parent2268a4147ec1e9f0236fd5eb56c1cc2b751eca05 (diff)
downloadrneovim-300490f2e8e94ee471685cd9809964c10ebdc1ed.tar.gz
rneovim-300490f2e8e94ee471685cd9809964c10ebdc1ed.tar.bz2
rneovim-300490f2e8e94ee471685cd9809964c10ebdc1ed.zip
vim-patch:8.2.0049: command line completion not fully tested
Problem: Command line completion not fully tested. Solution: Add more test cases. Make help sorting stable. (Dominique Pelle, closes vim/vim#5402) https://github.com/vim/vim/commit/297610ba4b110c918ffe60c45eb4a1d6ea2daae5
-rw-r--r--src/nvim/ex_cmds.c10
-rw-r--r--src/nvim/testdir/test_cd.vim15
-rw-r--r--src/nvim/testdir/test_cmdline.vim9
-rw-r--r--src/nvim/testdir/test_help.vim5
-rw-r--r--src/nvim/testdir/test_menu.vim4
-rw-r--r--src/nvim/testdir/test_options.vim7
-rw-r--r--src/nvim/testdir/test_syntax.vim6
7 files changed, 55 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 82422a78c3..b5b75b76a9 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -5019,7 +5019,15 @@ static int help_compare(const void *s1, const void *s2)
p1 = *(char **)s1 + strlen(*(char **)s1) + 1;
p2 = *(char **)s2 + strlen(*(char **)s2) + 1;
- return strcmp(p1, p2);
+
+ // Compare by help heuristic number first.
+ int 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);
}
/// Find all help tags matching "arg", sort them and return in matches[], with
diff --git a/src/nvim/testdir/test_cd.vim b/src/nvim/testdir/test_cd.vim
index c364babd65..a1e53df774 100644
--- a/src/nvim/testdir/test_cd.vim
+++ b/src/nvim/testdir/test_cd.vim
@@ -225,6 +225,21 @@ func Test_cd_from_non_existing_dir()
call assert_equal(saveddir, getcwd())
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
+
func Test_cd_unknown_dir()
call mkdir('Xa')
cd Xa
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 8d1746be2f..8574573d8c 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -757,6 +757,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_complete_expression()
let g:SomeVar = 'blah'
for cmd in ['exe', 'echo', 'echon', 'echomsg']
diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim
index 9569cfa4e5..dbb36facee 100644
--- a/src/nvim/testdir/test_help.vim
+++ b/src/nvim/testdir/test_help.vim
@@ -92,6 +92,11 @@ func Test_help_local_additions()
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
+
" Test for the :helptags command
func Test_helptag_cmd()
call mkdir('Xdir/a/doc', 'p')
diff --git a/src/nvim/testdir/test_menu.vim b/src/nvim/testdir/test_menu.vim
index eb25e41990..61c3a16125 100644
--- a/src/nvim/testdir/test_menu.vim
+++ b/src/nvim/testdir/test_menu.vim
@@ -46,6 +46,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/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index f73cd5f5e6..2a3d977254 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -238,6 +238,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')
@@ -268,6 +274,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&
" Expand values for 'filetype'
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 9f50b3c241..4d1a468e30 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -197,6 +197,12 @@ 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', @:)
+ call assert_equal('"echohl NonText Normal NormalFloat NormalNC none', @:)
+endfunc
+
func Test_syntax_arg_skipped()
syn clear
syntax case ignore