comparison 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
comparison
equal deleted inserted replaced
26194:9dab308df27e 26195:41b3718d84c3
371 call assert_equal("jump jump", getline(1)) 371 call assert_equal("jump jump", getline(1))
372 bwipe! 372 bwipe!
373 set completeopt& 373 set completeopt&
374 endfunc 374 endfunc
375 375
376 func s:ComplInCmdwin_GlobalCompletion(a, l, p)
377 return 'global'
378 endfunc
379
380 func s:ComplInCmdwin_LocalCompletion(a, l, p)
381 return 'local'
382 endfunc
383
376 func Test_compl_in_cmdwin() 384 func Test_compl_in_cmdwin()
377 CheckFeature cmdwin 385 CheckFeature cmdwin
378 386
379 set wildmenu wildchar=<Tab> 387 set wildmenu wildchar=<Tab>
380 com! -nargs=1 -complete=command GetInput let input = <q-args> 388 com! -nargs=1 -complete=command GetInput let input = <q-args>
409 417
410 let input = '' 418 let input = ''
411 call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!') 419 call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
412 call assert_equal('b:test_', input) 420 call assert_equal('b:test_', input)
413 421
422
423 " Argument completion of buffer-local command
424 func s:ComplInCmdwin_GlobalCompletionList(a, l, p)
425 return ['global']
426 endfunc
427
428 func s:ComplInCmdwin_LocalCompletionList(a, l, p)
429 return ['local']
430 endfunc
431
432 func s:ComplInCmdwin_CheckCompletion(arg)
433 call assert_equal('local', a:arg)
434 endfunc
435
436 com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion
437 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
438 com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion
439 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
440 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
441
442 com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList
443 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
444 com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList
445 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
446
447 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
448
449 func! s:ComplInCmdwin_CheckCompletion(arg)
450 call assert_equal('global', a:arg)
451 endfunc
452 new
453 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
454 quit
455
456 delfunc s:ComplInCmdwin_GlobalCompletion
457 delfunc s:ComplInCmdwin_LocalCompletion
458 delfunc s:ComplInCmdwin_GlobalCompletionList
459 delfunc s:ComplInCmdwin_LocalCompletionList
460 delfunc s:ComplInCmdwin_CheckCompletion
461
462 delcom -buffer TestCommand
414 delcom TestCommand 463 delcom TestCommand
415 delcom GetInput 464 delcom GetInput
416 unlet w:test_winvar 465 unlet w:test_winvar
417 unlet b:test_bufvar 466 unlet b:test_bufvar
418 set wildmenu& wildchar& 467 set wildmenu& wildchar&