aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-16 15:43:25 +0800
committerGitHub <noreply@github.com>2024-07-16 15:43:25 +0800
commit08abb64680c0fb6d31546be22686db4997564b9c (patch)
treeaea29316cc014f8be609d96abed6726176f90332
parent0bbccf7c5f4f13b57c027d734dc5086c15d0abda (diff)
parent7e5c5b4d853b05eee04bc01f2b5e0571d662f9c7 (diff)
downloadrneovim-08abb64680c0fb6d31546be22686db4997564b9c.tar.gz
rneovim-08abb64680c0fb6d31546be22686db4997564b9c.tar.bz2
rneovim-08abb64680c0fb6d31546be22686db4997564b9c.zip
Merge pull request #29741 from zeertzjq/vim-8.2.1651
vim-patch:8.2.{1651,1659}
-rw-r--r--src/nvim/spellfile.c4
-rw-r--r--test/old/testdir/test_spell.vim1
-rw-r--r--test/old/testdir/test_spellfile.vim98
3 files changed, 101 insertions, 2 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index ddeab218e1..ae8c243486 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -4105,8 +4105,8 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root, const char *n
perc = (tot - n) * 100 / tot;
}
vim_snprintf(IObuff, IOSIZE,
- _("Compressed %s of %d nodes; %d (%ld%%) remaining"),
- name, tot, tot - n, perc);
+ _("Compressed %s: %d of %d nodes; %d (%ld%%) remaining"),
+ name, n, tot, tot - n, perc);
spell_message(spin, IObuff);
}
#ifdef SPELL_PRINTTREE
diff --git a/test/old/testdir/test_spell.vim b/test/old/testdir/test_spell.vim
index d55a51e8eb..643744d817 100644
--- a/test/old/testdir/test_spell.vim
+++ b/test/old/testdir/test_spell.vim
@@ -125,6 +125,7 @@ foobar/?
set spelllang=
call assert_fails("call spellbadword('maxch')", 'E756:')
+ call assert_fails("spelldump", 'E756:')
call delete('Xwords.spl')
call delete('Xwords')
diff --git a/test/old/testdir/test_spellfile.vim b/test/old/testdir/test_spellfile.vim
index 509fed11df..50621144bd 100644
--- a/test/old/testdir/test_spellfile.vim
+++ b/test/old/testdir/test_spellfile.vim
@@ -191,6 +191,11 @@ func Spellfile_Test(content, emsg)
" Add the spell file header and version (VIMspell2)
let v = 0z56494D7370656C6C32 + a:content
call writefile(v, splfile, 'b')
+
+ " 'encoding' is set before each test to clear the previously loaded suggest
+ " file from memory.
+ set encoding=utf-8
+
set runtimepath=./Xtest
set spelllang=Xtest
if a:emsg != ''
@@ -311,6 +316,12 @@ func Test_spellfile_format_error()
" SN_SOFO: missing sofoto
call Spellfile_Test(0z0600000000050001610000, 'E759:')
+ " SN_SOFO: empty sofofrom and sofoto
+ call Spellfile_Test(0z06000000000400000000FF000000000000000000000000, '')
+
+ " SN_SOFO: multi-byte characters in sofofrom and sofoto
+ call Spellfile_Test(0z0600000000080002CF810002CF82FF000000000000000000000000, '')
+
" SN_COMPOUND: compmax is less than 2
call Spellfile_Test(0z08000000000101, 'E759:')
@@ -320,6 +331,12 @@ func Test_spellfile_format_error()
" SN_COMPOUND: missing compoptions
call Spellfile_Test(0z080000000005040101, 'E758:')
+ " SN_COMPOUND: missing comppattern
+ call Spellfile_Test(0z08000000000704010100000001, 'E758:')
+
+ " SN_COMPOUND: incorrect comppatlen
+ call Spellfile_Test(0z080000000007040101000000020165, 'E758:')
+
" SN_INFO: missing info
call Spellfile_Test(0z0F0000000005040101, '')
@@ -329,6 +346,12 @@ func Test_spellfile_format_error()
" SN_MAP: missing midword
call Spellfile_Test(0z0700000000040102, '')
+ " SN_MAP: empty map string
+ call Spellfile_Test(0z070000000000FF000000000000000000000000, '')
+
+ " SN_MAP: duplicate multibyte character
+ call Spellfile_Test(0z070000000004DC81DC81, 'E783:')
+
" SN_SYLLABLE: missing SYLLABLE item
call Spellfile_Test(0z0900000000040102, '')
@@ -345,12 +368,21 @@ func Test_spellfile_format_error()
" LWORDTREE: missing tree node value
call Spellfile_Test(0zFF0000000402, 'E758:')
+ " LWORDTREE: incorrect sibling node count
+ call Spellfile_Test(0zFF00000001040000000000000000, 'E759:')
+
" KWORDTREE: missing tree node
call Spellfile_Test(0zFF0000000000000004, 'E758:')
" PREFIXTREE: missing tree node
call Spellfile_Test(0zFF000000000000000000000004, 'E758:')
+ " PREFIXTREE: incorrect prefcondnr
+ call Spellfile_Test(0zFF000000000000000000000002010200000020, 'E759:')
+
+ " PREFIXTREE: invalid nodeidx
+ call Spellfile_Test(0zFF00000000000000000000000201010000, 'E759:')
+
let &rtp = save_rtp
call delete('Xtest', 'rf')
endfunc
@@ -518,6 +550,14 @@ func Test_wordlist_dic()
let output = execute('mkspell! -ascii Xwordlist.spl Xwordlist.dic')
call assert_match('Ignored 1 words with non-ASCII characters', output)
+ " keep case of a word
+ let lines =<< trim [END]
+ example/=
+ [END]
+ call writefile(lines, 'Xwordlist.dic')
+ let output = execute('mkspell! Xwordlist.spl Xwordlist.dic')
+ call assert_match('Compressed keep-case:', output)
+
call delete('Xwordlist.spl')
call delete('Xwordlist.dic')
endfunc
@@ -525,8 +565,14 @@ endfunc
" Test for the :mkspell command
func Test_mkspell()
call assert_fails('mkspell Xtest_us.spl', 'E751:')
+ call assert_fails('mkspell Xtest.spl abc', 'E484:')
call assert_fails('mkspell a b c d e f g h i j k', 'E754:')
+ " create a .aff file but not the .dic file
+ call writefile([], 'Xtest.aff')
+ call assert_fails('mkspell Xtest.spl Xtest', 'E484:')
+ call delete('Xtest.aff')
+
call writefile([], 'Xtest.spl')
call writefile([], 'Xtest.dic')
call assert_fails('mkspell Xtest.spl Xtest.dic', 'E13:')
@@ -730,6 +776,44 @@ func Test_aff_file_format_error()
let output = execute('mkspell! Xtest.spl Xtest')
call assert_match('Illegal flag in Xtest.aff line 2: L', output)
+ " Nvim: non-utf8 encoding not supported
+ " " missing character in UPP entry. The character table is used only in a
+ " " non-utf8 encoding
+ " call writefile(['FOL abc', 'LOW abc', 'UPP A'], 'Xtest.aff')
+ " let save_encoding = &encoding
+ " set encoding=cp949
+ " call assert_fails('mkspell! Xtest.spl Xtest', 'E761:')
+ " let &encoding = save_encoding
+ "
+ " " character range doesn't match between FOL and LOW entries
+ " call writefile(["FOL \u0102bc", 'LOW abc', 'UPP ABC'], 'Xtest.aff')
+ " let save_encoding = &encoding
+ " set encoding=cp949
+ " call assert_fails('mkspell! Xtest.spl Xtest', 'E762:')
+ " let &encoding = save_encoding
+ "
+ " " character range doesn't match between FOL and UPP entries
+ " call writefile(["FOL \u0102bc", "LOW \u0102bc", 'UPP ABC'], 'Xtest.aff')
+ " let save_encoding = &encoding
+ " set encoding=cp949
+ " call assert_fails('mkspell! Xtest.spl Xtest', 'E762:')
+ " let &encoding = save_encoding
+ "
+ " " additional characters in LOW and UPP entries
+ " call writefile(["FOL ab", "LOW abc", 'UPP ABC'], 'Xtest.aff')
+ " let save_encoding = &encoding
+ " set encoding=cp949
+ " call assert_fails('mkspell! Xtest.spl Xtest', 'E761:')
+ " let &encoding = save_encoding
+ "
+ " " missing UPP entry
+ " call writefile(["FOL abc", "LOW abc"], 'Xtest.aff')
+ " let save_encoding = &encoding
+ " set encoding=cp949
+ " let output = execute('mkspell! Xtest.spl Xtest')
+ " call assert_match('Missing FOL/LOW/UPP line in Xtest.aff', output)
+ " let &encoding = save_encoding
+
" duplicate word in the .dic file
call writefile(['2', 'good', 'good', 'good'], 'Xtest.dic')
call writefile(['NAME vim'], 'Xtest.aff')
@@ -737,6 +821,20 @@ func Test_aff_file_format_error()
call assert_match('First duplicate word in Xtest.dic line 3: good', output)
call assert_match('2 duplicate word(s) in Xtest.dic', output)
+ " use multiple .aff files with different values for COMPOUNDWORDMAX and
+ " MIDWORD (number and string)
+ call writefile(['1', 'world'], 'Xtest_US.dic')
+ call writefile(['1', 'world'], 'Xtest_CA.dic')
+ call writefile(["COMPOUNDWORDMAX 3", "MIDWORD '-"], 'Xtest_US.aff')
+ call writefile(["COMPOUNDWORDMAX 4", "MIDWORD '="], 'Xtest_CA.aff')
+ let output = execute('mkspell! Xtest.spl Xtest_US Xtest_CA')
+ call assert_match('COMPOUNDWORDMAX value differs from what is used in another .aff file', output)
+ call assert_match('MIDWORD value differs from what is used in another .aff file', output)
+ call delete('Xtest_US.dic')
+ call delete('Xtest_CA.dic')
+ call delete('Xtest_US.aff')
+ call delete('Xtest_CA.aff')
+
call delete('Xtest.dic')
call delete('Xtest.aff')
call delete('Xtest.spl')