diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2021-10-16 18:40:57 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2021-10-23 22:30:50 +0200 |
commit | cbec765915a8a76e86ac79dde8eeae663b019882 (patch) | |
tree | 9d626c255ef9e827d3169672a8127995e8289da1 /src/nvim/testdir | |
parent | aa4f0879e35c43b186cf51c50f28847dd2df256c (diff) | |
download | rneovim-cbec765915a8a76e86ac79dde8eeae663b019882.tar.gz rneovim-cbec765915a8a76e86ac79dde8eeae663b019882.tar.bz2 rneovim-cbec765915a8a76e86ac79dde8eeae663b019882.zip |
vim-patch:8.2.3520: cannot define a function for thesaurus completion
Problem: Cannot define a function for thesaurus completion.
Solution: Add 'thesaurusfunc'. (Yegappan Lakshmanan, closes vim/vim#8987,
closes 8950)
https://github.com/vim/vim/commit/160e994d768d03a3c826b58115cde94df8fce607
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r-- | src/nvim/testdir/test_edit.vim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 2b389c015f..9a35129232 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -870,6 +870,48 @@ func Test_edit_CTRL_T() bw! endfunc +" Test 'thesaurusfunc' +func MyThesaurus(findstart, base) + let mythesaurus = [ + \ #{word: "happy", + \ synonyms: "cheerful,blissful,flying high,looking good,peppy"}, + \ #{word: "kind", + \ synonyms: "amiable,bleeding-heart,heart in right place"}] + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + return start + else + " find strings matching with "a:base" + let res = [] + for w in mythesaurus + if w.word =~ '^' . a:base + call add(res, w.word) + call extend(res, split(w.synonyms, ",")) + endif + endfor + return res + endif +endfunc + +func Test_thesaurus_func() + new + set thesaurus= + set thesaurusfunc=MyThesaurus + call setline(1, "an ki") + call cursor(1, 1) + call feedkeys("A\<c-x>\<c-t>\<c-n>\<cr>\<esc>", 'tnix') + call assert_equal(['an amiable', ''], getline(1, '$')) + set thesaurusfunc=NonExistingFunc + call assert_fails("normal $a\<C-X>\<C-T>", 'E117:') + set thesaurusfunc& + %bw! +endfunc + func Test_edit_CTRL_U() " Test 'completefunc' new |