diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-04 13:43:23 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-05-04 13:48:52 +0800 |
commit | 7e70a1e44b223a51f4d8f06b9fe4c4ef77601f83 (patch) | |
tree | 293255262ee3b8bb4ad4c5b6079c95930019029d | |
parent | a1bd31e6010c803fd842db6bdb0d531a71e67837 (diff) | |
download | rneovim-7e70a1e44b223a51f4d8f06b9fe4c4ef77601f83.tar.gz rneovim-7e70a1e44b223a51f4d8f06b9fe4c4ef77601f83.tar.bz2 rneovim-7e70a1e44b223a51f4d8f06b9fe4c4ef77601f83.zip |
vim-patch:9.0.0138: not enough characters accepted for 'spellfile'
Problem: Not enough characters accepted for 'spellfile'.
Solution: Add vim_is_fname_char() and use it for 'spellfile'.
https://github.com/vim/vim/commit/bc49c5f48f89c2d6f4d88ee77f44a11d68293be3
Cherry-pick related doc update from Vim runtime.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | runtime/doc/options.txt | 1 | ||||
-rw-r--r-- | src/nvim/charset.c | 12 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | test/old/testdir/test_spellfile.vim | 8 |
4 files changed, 21 insertions, 2 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index ab86e56a62..324151ee58 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5706,6 +5706,7 @@ A jump table for the options with a short description can be found at |Q_op|. Name of the word list file where words are added for the |zg| and |zw| commands. It must end in ".{encoding}.add". You need to include the path, otherwise the file is placed in the current directory. + The path may include characters from 'isfname', space, comma and '@'. *E765* It may also be a comma-separated list of names. A count before the |zg| and |zw| commands can be used to access each. This allows using diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 3d4e0abda9..8cae831881 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -858,8 +858,10 @@ bool vim_iswordp_buf(const char *const p, buf_T *const buf) return vim_iswordc_buf(c, buf); } -/// Check that "c" is a valid file-name character. +/// Check that "c" is a valid file-name character as specified with the +/// 'isfname' option. /// Assume characters above 0x100 are valid (multi-byte). +/// To be used for commands like "gf". /// /// @param c character to check bool vim_isfilec(int c) @@ -868,6 +870,14 @@ bool vim_isfilec(int c) return c >= 0x100 || (c > 0 && (g_chartab[c] & CT_FNAME_CHAR)); } +/// Check if "c" is a valid file-name character, including characters left +/// out of 'isfname' to make "gf" work, such as comma, space, '@', etc. +bool vim_is_fname_char(int c) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + return vim_isfilec(c) || c == ',' || c == ' ' || c == '@'; +} + /// Check that "c" is a valid file-name character or a wildcard character /// Assume characters above 0x100 are valid (multi-byte). /// Explicitly interpret ']' as a wildcard character as path_has_wildcard("]") diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d1d1b9180f..84875261f1 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3621,7 +3621,7 @@ bool valid_spellfile(const char *val) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { for (const char *s = val; *s != NUL; s++) { - if (!vim_isfilec((uint8_t)(*s)) && *s != ',' && *s != ' ') { + if (!vim_is_fname_char((uint8_t)(*s))) { return false; } } diff --git a/test/old/testdir/test_spellfile.vim b/test/old/testdir/test_spellfile.vim index dbffbafed9..639ebc1c34 100644 --- a/test/old/testdir/test_spellfile.vim +++ b/test/old/testdir/test_spellfile.vim @@ -1063,4 +1063,12 @@ func Test_mkspellmem_opt() call assert_fails('set mkspellmem=1000,50,0', 'E474:') endfunc +" 'spellfile' accepts '@' on top of 'isfname'. +func Test_spellfile_allow_at_character() + call mkdir('Xtest/the foo@bar,dir', 'p') + let &spellfile = './Xtest/the foo@bar,dir/Xspellfile.add' + let &spellfile = '' + call delete('Xtest', 'rf') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |