diff src/testdir/test_ins_complete.vim @ 26195:41b3718d84c3 v8.2.3629

patch 8.2.3629: command completion in cmdline window uses global commands Commit: https://github.com/vim/vim/commit/a1198124370a366ff02811a43845a631b5c6e7f0 Author: mityu <mityu.mail@gmail.com> Date: Sat Nov 20 19:13:39 2021 +0000 patch 8.2.3629: command completion in cmdline window uses global commands Problem: Command completion in cmdline window uses global user commands, not local commands for the window where it was opened from. Solution: Use local commands. (closes #9168)
author Bram Moolenaar <Bram@vim.org>
date Sat, 20 Nov 2021 20:15:03 +0100
parents 31db9c6df4e3
children 485c7c4afeb7
line wrap: on
line diff
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -373,6 +373,14 @@ func Test_compl_feedkeys()
   set completeopt&
 endfunc
 
+func s:ComplInCmdwin_GlobalCompletion(a, l, p)
+  return 'global'
+endfunc
+
+func s:ComplInCmdwin_LocalCompletion(a, l, p)
+  return 'local'
+endfunc
+
 func Test_compl_in_cmdwin()
   CheckFeature cmdwin
 
@@ -411,6 +419,47 @@ func Test_compl_in_cmdwin()
   call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
   call assert_equal('b:test_', input)
 
+
+  " Argument completion of buffer-local command
+  func s:ComplInCmdwin_GlobalCompletionList(a, l, p)
+    return ['global']
+  endfunc
+
+  func s:ComplInCmdwin_LocalCompletionList(a, l, p)
+    return ['local']
+  endfunc
+
+  func s:ComplInCmdwin_CheckCompletion(arg)
+    call assert_equal('local', a:arg)
+  endfunc
+
+  com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion
+       \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
+  com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion
+       \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
+  call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
+
+  com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList
+       \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
+  com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList
+       \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
+
+  call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
+
+  func! s:ComplInCmdwin_CheckCompletion(arg)
+    call assert_equal('global', a:arg)
+  endfunc
+  new
+  call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
+  quit
+
+  delfunc s:ComplInCmdwin_GlobalCompletion
+  delfunc s:ComplInCmdwin_LocalCompletion
+  delfunc s:ComplInCmdwin_GlobalCompletionList
+  delfunc s:ComplInCmdwin_LocalCompletionList
+  delfunc s:ComplInCmdwin_CheckCompletion
+
+  delcom -buffer TestCommand
   delcom TestCommand
   delcom GetInput
   unlet w:test_winvar