diff options
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 |