Mercurial > vim
comparison src/testdir/test_vim9_import.vim @ 27285:53edd190a607 v8.2.4171
patch 8.2.4171: cannot invoke option function using autoload import
Commit: https://github.com/vim/vim/commit/f0e7e6365e86ca42c177fe165d3097d1bfb35f72
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 21 13:29:56 2022 +0000
patch 8.2.4171: cannot invoke option function using autoload import
Problem: Cannot invoke option function using autoload import.
Solution: Expand the import to an autoload function name. (closes https://github.com/vim/vim/issues/9578)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 21 Jan 2022 14:45:03 +0100 |
parents | b73e3617c1d6 |
children | e11682ba8c80 |
comparison
equal
deleted
inserted
replaced
27284:9010bd9efbf6 | 27285:53edd190a607 |
---|---|
607 delete('XsomeExport.vim') | 607 delete('XsomeExport.vim') |
608 delete('Xmapscript.vim') | 608 delete('Xmapscript.vim') |
609 nunmap <F3> | 609 nunmap <F3> |
610 enddef | 610 enddef |
611 | 611 |
612 def Test_use_import_in_completion() | 612 def Test_use_import_in_command_completion() |
613 var lines =<< trim END | 613 var lines =<< trim END |
614 vim9script | 614 vim9script |
615 export def Complete(..._): list<string> | 615 export def Complete(..._): list<string> |
616 return ['abcd'] | 616 return ['abcd'] |
617 enddef | 617 enddef |
628 END | 628 END |
629 CheckScriptSuccess(lines) | 629 CheckScriptSuccess(lines) |
630 | 630 |
631 delcommand Cmd | 631 delcommand Cmd |
632 delete('Xscript.vim') | 632 delete('Xscript.vim') |
633 enddef | |
634 | |
635 def Test_use_autoload_import_in_insert_completion() | |
636 mkdir('Xdir/autoload', 'p') | |
637 var save_rtp = &rtp | |
638 exe 'set rtp^=' .. getcwd() .. '/Xdir' | |
639 | |
640 var lines =<< trim END | |
641 vim9script | |
642 export def ThesaurusFunc(findbase: bool, _): any | |
643 if findbase | |
644 return 1 | |
645 endif | |
646 return [ | |
647 'check', | |
648 'experiment', | |
649 'test', | |
650 'verification' | |
651 ] | |
652 enddef | |
653 g:completion_loaded = 'yes' | |
654 END | |
655 writefile(lines, 'Xdir/autoload/completion.vim') | |
656 | |
657 new | |
658 lines =<< trim END | |
659 vim9script | |
660 g:completion_loaded = 'no' | |
661 import autoload 'completion.vim' | |
662 set thesaurusfunc=completion.ThesaurusFunc | |
663 assert_equal('no', g:completion_loaded) | |
664 feedkeys("i\<C-X>\<C-T>\<C-N>\<Esc>", 'xt') | |
665 assert_equal('experiment', getline(1)) | |
666 assert_equal('yes', g:completion_loaded) | |
667 END | |
668 CheckScriptSuccess(lines) | |
669 | |
670 set thesaurusfunc= | |
671 bwipe! | |
672 delete('Xdir', 'rf') | |
673 &rtp = save_rtp | |
633 enddef | 674 enddef |
634 | 675 |
635 def Test_export_fails() | 676 def Test_export_fails() |
636 CheckScriptFailure(['export var some = 123'], 'E1042:') | 677 CheckScriptFailure(['export var some = 123'], 'E1042:') |
637 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') | 678 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |