spell: Fix argument and avoid redundant prompt.

In #3027 we deferred the "missing spell file" prompt until VimEnter, but
we were sending the wrong argument (should be "en", not "en_us").
This also caused redundant prompts if user answers "No" to the download
prompt invoked by the SpellFileMissing event.

Closes #3966
Closes #4406
This commit is contained in:
Justin M. Keyes 2016-04-10 02:20:53 -04:00
parent 3462f46cb8
commit 8d37201ed2
2 changed files with 8 additions and 12 deletions

View File

@ -1,15 +1,8 @@
" Vim plugin for downloading spell files " Vim plugin for downloading spell files
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2006 Feb 01
" Exit quickly when:
" - this plugin was already loaded
" - when 'compatible' is set
" - some autocommands are already taking care of spell files
if exists("loaded_spellfile_plugin") || &cp || exists("#SpellFileMissing") if exists("loaded_spellfile_plugin") || &cp || exists("#SpellFileMissing")
finish finish
endif endif
let loaded_spellfile_plugin = 1 let loaded_spellfile_plugin = 1
" The function is in the autoload directory.
autocmd SpellFileMissing * call spellfile#LoadFile(expand('<amatch>')) autocmd SpellFileMissing * call spellfile#LoadFile(expand('<amatch>'))

View File

@ -2332,14 +2332,17 @@ static void spell_load_lang(char_u *lang)
if (r == FAIL) { if (r == FAIL) {
if (starting) { if (starting) {
// Some startup file sets &spell, but the necessary files don't exist: // Prompt the user at VimEnter if spell files are missing. #3027
// try to prompt the user at VimEnter. Also set spell again. #3027 // Plugins aren't loaded yet, so spellfile.vim cannot handle this case.
do_cmdline_cmd( char autocmd_buf[128] = { 0 };
"autocmd VimEnter * call spellfile#LoadFile(&spelllang)|set spell"); snprintf(autocmd_buf, sizeof(autocmd_buf),
"autocmd VimEnter * call spellfile#LoadFile('%s')|set spell",
lang);
do_cmdline_cmd(autocmd_buf);
} else { } else {
smsg( smsg(
_("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), _("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""),
lang, spell_enc(), lang); lang, spell_enc(), lang);
} }
} else if (sl.sl_slang != NULL) { } else if (sl.sl_slang != NULL) {
// At least one file was loaded, now load ALL the additions. // At least one file was loaded, now load ALL the additions.