comparison src/testdir/test_popup.vim @ 16127:0375e54f0adc v8.1.1068

patch 8.1.1068: cannot get all the information about current completion commit https://github.com/vim/vim/commit/fd133323d4e1cc9c0e61c0ce357df4d36ea148e3 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 29 12:20:27 2019 +0100 patch 8.1.1068: cannot get all the information about current completion Problem: Cannot get all the information about current completion. Solution: Add complete_info(). (Shougo, Hirohito Higashi, closes https://github.com/vim/vim/issues/4106)
author Bram Moolenaar <Bram@vim.org>
date Fri, 29 Mar 2019 12:30:06 +0100
parents 6012cc6936f7
children 56451a2677dc
comparison
equal deleted inserted replaced
16126:b792e47f7a2d 16127:0375e54f0adc
894 catch 894 catch
895 call assert_exception('E328:') 895 call assert_exception('E328:')
896 endtry 896 endtry
897 endfunc 897 endfunc
898 898
899 func Test_popup_complete_info_01()
900 new
901 inoremap <buffer><F5> <C-R>=complete_info().mode<CR>
902 func s:complTestEval() abort
903 call complete(1, ['aa', 'ab'])
904 return ''
905 endfunc
906 inoremap <buffer><F6> <C-R>=s:complTestEval()<CR>
907 call writefile([
908 \ 'dummy dummy.txt 1',
909 \], 'Xdummy.txt')
910 setlocal tags=Xdummy.txt
911 setlocal dictionary=Xdummy.txt
912 setlocal thesaurus=Xdummy.txt
913 setlocal omnifunc=syntaxcomplete#Complete
914 setlocal completefunc=syntaxcomplete#Complete
915 setlocal spell
916 for [keys, mode_name] in [
917 \ ["", ''],
918 \ ["\<C-X>", 'ctrl_x'],
919 \ ["\<C-X>\<C-N>", 'keyword'],
920 \ ["\<C-X>\<C-P>", 'keyword'],
921 \ ["\<C-X>\<C-L>", 'whole_line'],
922 \ ["\<C-X>\<C-F>", 'files'],
923 \ ["\<C-X>\<C-]>", 'tags'],
924 \ ["\<C-X>\<C-D>", 'path_defines'],
925 \ ["\<C-X>\<C-I>", 'path_patterns'],
926 \ ["\<C-X>\<C-K>", 'dictionary'],
927 \ ["\<C-X>\<C-T>", 'thesaurus'],
928 \ ["\<C-X>\<C-V>", 'cmdline'],
929 \ ["\<C-X>\<C-U>", 'function'],
930 \ ["\<C-X>\<C-O>", 'omni'],
931 \ ["\<C-X>s", 'spell'],
932 \ ["\<F6>", 'eval'],
933 \]
934 call feedkeys("i" . keys . "\<F5>\<Esc>", 'tx')
935 call assert_equal(mode_name, getline('.'))
936 %d
937 endfor
938 call delete('Xdummy.txt')
939 bwipe!
940 endfunc
941
942 func UserDefinedComplete(findstart, base)
943 if a:findstart
944 return 0
945 else
946 return [
947 \ { 'word': 'Jan', 'menu': 'January' },
948 \ { 'word': 'Feb', 'menu': 'February' },
949 \ { 'word': 'Mar', 'menu': 'March' },
950 \ { 'word': 'Apr', 'menu': 'April' },
951 \ { 'word': 'May', 'menu': 'May' },
952 \ ]
953 endif
954 endfunc
955
956 func GetCompleteInfo()
957 if empty(g:compl_what)
958 let g:compl_info = complete_info()
959 else
960 let g:compl_info = complete_info(g:compl_what)
961 endif
962 return ''
963 endfunc
964
965 func Test_popup_complete_info_02()
966 new
967 inoremap <buffer><F5> <C-R>=GetCompleteInfo()<CR>
968 setlocal completefunc=UserDefinedComplete
969
970 let d = {
971 \ 'mode': 'function',
972 \ 'pum_visible': 1,
973 \ 'items': [
974 \ {'word': 'Jan', 'menu': 'January', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
975 \ {'word': 'Feb', 'menu': 'February', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
976 \ {'word': 'Mar', 'menu': 'March', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
977 \ {'word': 'Apr', 'menu': 'April', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''},
978 \ {'word': 'May', 'menu': 'May', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}
979 \ ],
980 \ 'selected': 0,
981 \ }
982
983 let g:compl_what = []
984 call feedkeys("i\<C-X>\<C-U>\<F5>", 'tx')
985 call assert_equal(d, g:compl_info)
986
987 let g:compl_what = ['mode', 'pum_visible', 'selected']
988 call remove(d, 'items')
989 call feedkeys("i\<C-X>\<C-U>\<F5>", 'tx')
990 call assert_equal(d, g:compl_info)
991
992 let g:compl_what = ['mode']
993 call remove(d, 'selected')
994 call remove(d, 'pum_visible')
995 call feedkeys("i\<C-X>\<C-U>\<F5>", 'tx')
996 call assert_equal(d, g:compl_info)
997 bwipe!
998 endfunc
999
899 " vim: shiftwidth=2 sts=2 expandtab 1000 " vim: shiftwidth=2 sts=2 expandtab