diff options
| author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-06-12 15:07:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-12 15:07:11 -0400 |
| commit | 12d8ff7ccdad4d5873347e8d318a47ac552941d7 (patch) | |
| tree | f7167b901cd2fa667a4a835fe9153d5411b678ab /src/nvim/spellfile.c | |
| parent | d3bdde0bad12458128fae817aa348ac1d07b6f35 (diff) | |
| parent | 6a4685fb0e62dbd7955f8698e3aa82f885026036 (diff) | |
| download | rneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.tar.gz rneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.tar.bz2 rneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.zip | |
Merge pull request #14785 from janlazo/vim-8.1.1838
vim-patch:8.1.{1838,1865},8.2.{38,39,46,945,948,2896}
Diffstat (limited to 'src/nvim/spellfile.c')
| -rw-r--r-- | src/nvim/spellfile.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 145cfe4fc6..0597f392e7 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -5290,13 +5290,16 @@ static void spell_message(const spellinfo_T *spin, char_u *str) } // ":[count]spellgood {word}" -// ":[count]spellwrong {word}" +// ":[count]spellwrong {word}" // ":[count]spellundo {word}" +// ":[count]spellrare {word}" void ex_spell(exarg_T *eap) { - spell_add_word(eap->arg, (int)STRLEN(eap->arg), eap->cmdidx == CMD_spellwrong, - eap->forceit ? 0 : (int)eap->line2, - eap->cmdidx == CMD_spellundo); + spell_add_word(eap->arg, (int)STRLEN(eap->arg), + eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD : + eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD, + eap->forceit ? 0 : (int)eap->line2, + eap->cmdidx == CMD_spellundo); } // Add "word[len]" to 'spellfile' as a good or bad word. @@ -5304,10 +5307,10 @@ void spell_add_word ( char_u *word, int len, - int bad, - int idx, // "zG" and "zW": zero, otherwise index in - // 'spellfile' - bool undo // true for "zug", "zuG", "zuw" and "zuW" + SpellAddType what, // SPELL_ADD_ values + int idx, // "zG" and "zW": zero, otherwise index in + // 'spellfile' + bool undo // true for "zug", "zuG", "zuw" and "zuW" ) { FILE *fd = NULL; @@ -5364,7 +5367,7 @@ spell_add_word ( fname = fnamebuf; } - if (bad || undo) { + if (what == SPELL_ADD_BAD || undo) { // When the word appears as good word we need to remove that one, // since its flags sort before the one with WF_BANNED. fd = os_fopen((char *)fname, "r"); @@ -5422,13 +5425,16 @@ spell_add_word ( } } - if (fd == NULL) + if (fd == NULL) { EMSG2(_(e_notopen), fname); - else { - if (bad) + } else { + if (what == SPELL_ADD_BAD) { fprintf(fd, "%.*s/!\n", len, word); - else + } else if (what == SPELL_ADD_RARE) { + fprintf(fd, "%.*s/?\n", len, word); + } else { fprintf(fd, "%.*s\n", len, word); + } fclose(fd); home_replace(NULL, fname, NameBuff, MAXPATHL, TRUE); |
