diff src/testdir/test_cmdline.vim @ 28183:2b595cee4c85 v8.2.4617

patch 8.2.4617: no completion for :scriptnames Commit: https://github.com/vim/vim/commit/454ce6737cadb82886f1fc0eb9e8666cc59ae42b Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Mar 24 11:22:13 2022 +0000 patch 8.2.4617: no completion for :scriptnames Problem: No completion for :scriptnames. Solution: Implement :scriptnames completion. (Yegappan Lakshmanan, closes #10005)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Mar 2022 12:30:08 +0100
parents 130f4082a13d
children 553ff405b719
line wrap: on
line diff
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -3257,4 +3257,31 @@ func Test_cmdline_complete_breakdel()
   call assert_equal("\"breakdel here ", @:)
 endfunc
 
+" Test for :scriptnames argument completion
+func Test_cmdline_complete_scriptnames()
+  set wildmenu
+  call writefile(['let a = 1'], 'Xa1b2c3.vim')
+  source Xa1b2c3.vim
+  call feedkeys(":script \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx')
+  call assert_match("\"script .*Xa1b2c3.vim$", @:)
+  call feedkeys(":script    \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx')
+  call assert_match("\"script .*Xa1b2c3.vim$", @:)
+  call feedkeys(":script b2c3\<Tab>\<C-B>\"\<CR>", 'tx')
+  call assert_equal("\"script b2c3", @:)
+  call feedkeys(":script 2\<Tab>\<C-B>\"\<CR>", 'tx')
+  call assert_match("\"script 2\<Tab>$", @:)
+  call feedkeys(":script \<Tab>\<Left>\<Left> \<Tab>\<C-B>\"\<CR>", 'tx')
+  call assert_match("\"script .*Xa1b2c3.vim $", @:)
+  call feedkeys(":script \<Tab>\<Left>\<C-B>\"\<CR>", 'tx')
+  call assert_equal("\"script ", @:)
+  call assert_match('Xa1b2c3.vim$', getcompletion('.*Xa1b2.*', 'scriptnames')[0])
+  call assert_equal([], getcompletion('Xa1b2', 'scriptnames'))
+  new
+  call feedkeys(":script \<Tab>\<Left>\<Left>\<CR>", 'tx')
+  call assert_equal('Xa1b2c3.vim', fnamemodify(@%, ':t'))
+  bw!
+  call delete('Xa1b2c3.vim')
+  set wildmenu&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab