From 18888c15fc456040f860cfe55e1bf6be3dfd1dbe Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 24 Mar 2019 19:42:16 -0400 Subject: vim-patch:8.1.0199: spellbadword() does not check for caps error Problem: spellbadword() does not check for caps error. (Dominique Pelle) Solution: Adjust capcol when advancing. https://github.com/vim/vim/commit/66ab916935585391b2efaa8e39075e1ef94717b1 --- src/nvim/eval.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7ffa59f298..b6e292219f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16763,6 +16763,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, FunPtr fptr) break; } str += len; + capcol -= len; } } } -- cgit From d1ce15f696b719bef12c1e38875c6016c60aafac Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 24 Mar 2019 19:44:06 -0400 Subject: vim-patch:8.1.0200: spellbadword() not tested Problem: spellbadword() not tested. Solution: Add a test. (Dominique Pelle, closes vim/vim#3235) https://github.com/vim/vim/commit/872e451e8c326d5dd3062ef621fcbf0a4c5bef78 --- src/nvim/testdir/test_spell.vim | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index d7b8ca9e9c..230cb72335 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -69,6 +69,47 @@ func Test_z_equal_on_invalid_utf8_word() bwipe! endfunc +" Test spellbadword() with argument +func Test_spellbadword() + set spell + + call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.')) + call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence')) + + set spelllang=en + call assert_equal(['', ''], spellbadword('centre')) + call assert_equal(['', ''], spellbadword('center')) + set spelllang=en_us + call assert_equal(['centre', 'local'], spellbadword('centre')) + call assert_equal(['', ''], spellbadword('center')) + set spelllang=en_gb + call assert_equal(['', ''], spellbadword('centre')) + call assert_equal(['center', 'local'], spellbadword('center')) + + " Create a small word list to test that spellbadword('...') + " can return ['...', 'rare']. + e Xwords + insert +foo +foobar/? +. + w! + mkspell! Xwords.spl Xwords + set spelllang=Xwords.spl + call assert_equal(['foobar', 'rare'], spellbadword('foo foobar')) + + " Typo should not be detected without the 'spell' option. + set spelllang=en_gb nospell + call assert_equal(['', ''], spellbadword('centre')) + call assert_equal(['', ''], spellbadword('My bycycle.')) + call assert_equal(['', ''], spellbadword('A sentence. another sentence')) + + call delete('Xwords.spl') + call delete('Xwords') + set spelllang& + set spell& +endfunc + func Test_spellreall() new set spell -- cgit From 480794146fe09581d8459ea256e16e8e059b3f19 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 8 Aug 2019 21:40:29 -0400 Subject: f_spellbadword: set len=0 for non-found word `len` is used with `list_append_string` later, and should reflect the length of `word` (i.e. 0 when not setting word / breaking above). Ref: neovim/neovim#9782 (comment) --- src/nvim/eval.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b6e292219f..cc9dfcf27b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16764,6 +16764,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, FunPtr fptr) } str += len; capcol -= len; + len = 0; } } } -- cgit