From cbec765915a8a76e86ac79dde8eeae663b019882 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 16 Oct 2021 18:40:57 +0200 Subject: 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 --- src/nvim/testdir/test_edit.vim | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/nvim/testdir') 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\\\\\", 'tnix') + call assert_equal(['an amiable', ''], getline(1, '$')) + set thesaurusfunc=NonExistingFunc + call assert_fails("normal $a\\", 'E117:') + set thesaurusfunc& + %bw! +endfunc + func Test_edit_CTRL_U() " Test 'completefunc' new -- cgit From 36ff5976b9fee823892a1abcfb484cf3f162bb3b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 17 Oct 2021 16:22:28 +0200 Subject: vim-patch:8.2.3521: options completion test fails Problem: Options completion test fails. Solution: Add 'thesaurusfunc' to the results. https://github.com/vim/vim/commit/abdcfd1c837e244065d4fe04c7a78abae5af3f7e --- src/nvim/testdir/test_options.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') 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\\\"\", 'tx') - call assert_equal('"set tabstop thesaurus', @:) + call assert_equal('"set tabstop thesaurus thesaurusfunc', @:) " Expand current value call feedkeys(":set fileencodings=\\\"\", 'tx') -- cgit From 2dc0af3a4ff16d311169ce2ecd120dd05778039c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 17 Oct 2021 16:37:29 +0200 Subject: vim-patch:8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope Problem: 'thesaurus' and 'thesaurusfunc' do not have the same scope. Solution: Make 'thesaurusfunc' global-local. https://github.com/vim/vim/commit/f4d8b76d304dabc39c06d2344cd4c7b28484811b --- src/nvim/testdir/test_edit.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 9a35129232..23ad8dbfc5 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -900,16 +900,24 @@ endfunc func Test_thesaurus_func() new - set thesaurus= - set thesaurusfunc=MyThesaurus + set thesaurus=notused + set thesaurusfunc=NotUsed + setlocal thesaurusfunc=MyThesaurus call setline(1, "an ki") call cursor(1, 1) call feedkeys("A\\\\\", 'tnix') call assert_equal(['an amiable', ''], getline(1, '$')) + + setlocal thesaurusfunc=NonExistingFunc + call assert_fails("normal $a\\", 'E117:') + + setlocal thesaurusfunc= set thesaurusfunc=NonExistingFunc call assert_fails("normal $a\\", 'E117:') - set thesaurusfunc& %bw! + + set thesaurusfunc= + set thesaurus= endfunc func Test_edit_CTRL_U() -- cgit