diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-11-14 21:23:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-14 21:23:42 -0500 |
commit | 8f984dc1f29aa6ce41f233b983453bfd795e8238 (patch) | |
tree | 5655fff5088682c535be2ed5ca5d2146f5f05400 /src/nvim/testdir | |
parent | 3c74ba4acb87ebf7c5f2090ac9b4644cafec2495 (diff) | |
parent | 2dc0af3a4ff16d311169ce2ecd120dd05778039c (diff) | |
download | rneovim-8f984dc1f29aa6ce41f233b983453bfd795e8238.tar.gz rneovim-8f984dc1f29aa6ce41f233b983453bfd795e8238.tar.bz2 rneovim-8f984dc1f29aa6ce41f233b983453bfd795e8238.zip |
Merge pull request #16047 from mcepl/vim-8.2.3520
vim-patch:8.2.3520: cannot define a function for thesaurus completion
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r-- | src/nvim/testdir/test_edit.vim | 50 | ||||
-rw-r--r-- | src/nvim/testdir/test_options.vim | 2 |
2 files changed, 51 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 2b389c015f..23ad8dbfc5 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -870,6 +870,56 @@ 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=notused + set thesaurusfunc=NotUsed + setlocal 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, '$')) + + setlocal thesaurusfunc=NonExistingFunc + call assert_fails("normal $a\<C-X>\<C-T>", 'E117:') + + setlocal thesaurusfunc= + set thesaurusfunc=NonExistingFunc + call assert_fails("normal $a\<C-X>\<C-T>", 'E117:') + %bw! + + set thesaurusfunc= + set thesaurus= +endfunc + func Test_edit_CTRL_U() " Test 'completefunc' new diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 72c151142d..41c689849b 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -209,7 +209,7 @@ func Test_set_completion() " Expand abbreviation of options. call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx') - call assert_equal('"set tabstop thesaurus', @:) + call assert_equal('"set tabstop thesaurus thesaurusfunc', @:) " Expand current value call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx') |