mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
vim-patch:8.1.1144: too strict checking of the 'spellfile' option
Problem: Too strict checking of the 'spellfile' option.
Solution: Allow for a path.
862f1e17ea
This commit is contained in:
@@ -2538,6 +2538,18 @@ bool valid_spellang(const char_u *val)
|
|||||||
return valid_name(val, ".-_,");
|
return valid_name(val, ".-_,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return true if "val" is a valid 'spellfile' value.
|
||||||
|
static bool valid_spellfile(const char_u *val)
|
||||||
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
for (const char_u *s = val; *s != NUL; s++) {
|
||||||
|
if (!vim_isfilec(*s) && *s != ',') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Handle string options that need some action to perform when changed.
|
/// Handle string options that need some action to perform when changed.
|
||||||
/// Returns NULL for success, or an error message for an error.
|
/// Returns NULL for success, or an error message for an error.
|
||||||
static char_u *
|
static char_u *
|
||||||
@@ -3049,10 +3061,13 @@ ambw_end:
|
|||||||
|| varp == &(curwin->w_s->b_p_spf)) {
|
|| varp == &(curwin->w_s->b_p_spf)) {
|
||||||
// When 'spelllang' or 'spellfile' is set and there is a window for this
|
// When 'spelllang' or 'spellfile' is set and there is a window for this
|
||||||
// buffer in which 'spell' is set load the wordlists.
|
// buffer in which 'spell' is set load the wordlists.
|
||||||
if (!valid_spellang(*varp)) {
|
const bool is_spellfile = varp == &(curwin->w_s->b_p_spf);
|
||||||
|
|
||||||
|
if ((is_spellfile && !valid_spellfile(*varp))
|
||||||
|
|| (!is_spellfile && !valid_spellang(*varp))) {
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
} else {
|
} else {
|
||||||
errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
|
errmsg = did_set_spell_option(is_spellfile);
|
||||||
}
|
}
|
||||||
} else if (varp == &(curwin->w_s->b_p_spc)) {
|
} else if (varp == &(curwin->w_s->b_p_spc)) {
|
||||||
// When 'spellcapcheck' is set compile the regexp program.
|
// When 'spellcapcheck' is set compile the regexp program.
|
||||||
|
@@ -392,6 +392,11 @@ func Test_zz_sal_and_addition()
|
|||||||
call assert_equal("elekwint", SecondSpellWord())
|
call assert_equal("elekwint", SecondSpellWord())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_spellfile_value()
|
||||||
|
set spellfile=Xdir/Xtest.latin1.add
|
||||||
|
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_region_error()
|
func Test_region_error()
|
||||||
messages clear
|
messages clear
|
||||||
call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
|
call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
|
||||||
|
Reference in New Issue
Block a user