diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-22 18:38:51 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-22 18:38:51 +0000 |
commit | 3770f4c9cde7b5fcd10b6fa2e665cd0b69450fb2 (patch) | |
tree | 2537444947feb570db10bbf8472aae375fdc7d16 /src/testdir | |
parent | f3da4c8427b1b12d7aaffa307ec085ca97ea9ad9 (diff) | |
download | vim-git-9.0.1231.tar.gz |
patch 9.0.1231: completion of :runtime does not handle {where} argumentv9.0.1231
Problem: Completion of :runtime does not handle {where} argument.
Solution: Parse the {where} argument. (closes #11863)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_cmdline.vim | 9 | ||||
-rw-r--r-- | src/testdir/test_packadd.vim | 64 |
2 files changed, 64 insertions, 9 deletions
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 8ed89c689..23d6b4c92 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -553,15 +553,6 @@ func Test_getcompletion() call assert_true(index(l, '<buffer>') >= 0) let l = getcompletion('not', 'mapclear') call assert_equal([], l) - - let l = getcompletion('', 'runtime') - call assert_true(index(l, 'defaults.vim') >= 0) - let l = getcompletion('synt', 'runtime') - call assert_true(index(l, 'syntax') >= 0) - let l = getcompletion('syntax/vi', 'runtime') - call assert_true(index(l, 'syntax/vim.vim') >= 0) - let l = getcompletion('notexitsts', 'runtime') - call assert_equal([], l) let l = getcompletion('.', 'shellcmd') call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"')) diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim index 09fbcc00a..b5583ae73 100644 --- a/src/testdir/test_packadd.vim +++ b/src/testdir/test_packadd.vim @@ -190,8 +190,10 @@ func Test_packadd_completion() call mkdir(optdir1 . '/pluginA', 'p') call mkdir(optdir1 . '/pluginC', 'p') + call writefile([], optdir1 . '/unrelated') call mkdir(optdir2 . '/pluginB', 'p') call mkdir(optdir2 . '/pluginC', 'p') + call writefile([], optdir2 . '/unrelated') let li = [] call feedkeys(":packadd \<Tab>')\<C-B>call add(li, '\<CR>", 't') @@ -367,4 +369,66 @@ func Test_runtime() call assert_equal('runstartopt', g:sequence) endfunc +func Test_runtime_completion() + let rundir = &packpath . '/runtime/Xextra' + let startdir = &packpath . '/pack/mine/start/foo/Xextra' + let optdir = &packpath . '/pack/mine/opt/bar/Xextra' + call mkdir(rundir . '/Xrunbaz', 'p') + call mkdir(startdir . '/Xstartbaz', 'p') + call mkdir(optdir . '/Xoptbaz', 'p') + call writefile([], rundir . '/../Xrunfoo.vim') + call writefile([], rundir . '/Xrunbar.vim') + call writefile([], rundir . '/Xunrelated') + call writefile([], rundir . '/../Xunrelated') + call writefile([], startdir . '/../Xstartfoo.vim') + call writefile([], startdir . '/Xstartbar.vim') + call writefile([], startdir . '/Xunrelated') + call writefile([], startdir . '/../Xunrelated') + call writefile([], optdir . '/../Xoptfoo.vim') + call writefile([], optdir . '/Xoptbar.vim') + call writefile([], optdir . '/Xunrelated') + call writefile([], optdir . '/../Xunrelated') + exe 'set rtp=' . &packpath . '/runtime' + + func Check_runtime_completion(arg, arg1, res) + call feedkeys(':runtime ' .. a:arg .. "\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"runtime ' .. a:arg1 .. join(a:res), @:) + call assert_equal(a:res, getcompletion(a:arg, 'runtime')) + + call feedkeys(':runtime ' .. a:arg .. "X\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"runtime ' .. a:arg1 .. join(a:res), @:) + call assert_equal(a:res, getcompletion(a:arg .. 'X', 'runtime')) + endfunc + + call Check_runtime_completion('', '', + \ ['Xextra/', 'Xrunfoo.vim']) + call Check_runtime_completion('Xextra/', '', + \ ['Xextra/Xrunbar.vim', 'Xextra/Xrunbaz/']) + + call Check_runtime_completion('START ', 'START ', + \ ['Xextra/', 'Xstartfoo.vim']) + call Check_runtime_completion('START Xextra/', 'START ', + \ ['Xextra/Xstartbar.vim', 'Xextra/Xstartbaz/']) + + call Check_runtime_completion('OPT ', 'OPT ', + \ ['Xextra/', 'Xoptfoo.vim']) + call Check_runtime_completion('OPT Xextra/', 'OPT ', + \ ['Xextra/Xoptbar.vim', 'Xextra/Xoptbaz/']) + + call Check_runtime_completion('PACK ', 'PACK ', + \ ['Xextra/', 'Xoptfoo.vim', 'Xstartfoo.vim']) + call Check_runtime_completion('PACK Xextra/', 'PACK ', + \ ['Xextra/Xoptbar.vim', 'Xextra/Xoptbaz/', + \ 'Xextra/Xstartbar.vim', 'Xextra/Xstartbaz/']) + + call Check_runtime_completion('ALL ', 'ALL ', + \ ['Xextra/', 'Xoptfoo.vim', 'Xrunfoo.vim', 'Xstartfoo.vim']) + call Check_runtime_completion('ALL Xextra/', 'ALL ', + \ ['Xextra/Xoptbar.vim', 'Xextra/Xoptbaz/', + \ 'Xextra/Xrunbar.vim', 'Xextra/Xrunbaz/', + \ 'Xextra/Xstartbar.vim', 'Xextra/Xstartbaz/']) + + delfunc Check_runtime_completion +endfunc + " vim: shiftwidth=2 sts=2 expandtab |