aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-01 12:30:55 +0800
committerGitHub <noreply@github.com>2023-05-01 12:30:55 +0800
commita803bff89c89cc63e549a3c791fa07d91d1106c8 (patch)
tree23503fa40adaf199dea7e6c9302385ac8e1e42be /src
parent9f9cef1b569e226a87c5c74e455bc4fc76cc2fac (diff)
downloadrneovim-a803bff89c89cc63e549a3c791fa07d91d1106c8.tar.gz
rneovim-a803bff89c89cc63e549a3c791fa07d91d1106c8.tar.bz2
rneovim-a803bff89c89cc63e549a3c791fa07d91d1106c8.zip
fix(spell): extmark with spell=false should disable spell (#23400)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/spell.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 0784c4c8ff..d1d1b9180f 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1206,8 +1206,8 @@ static void decor_spell_nav_start(win_T *wp)
decor_redraw_reset(wp, &decor_state);
}
-static bool decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_lnum, int col,
- char **decor_error)
+static TriState decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_lnum, int col,
+ char **decor_error)
{
if (*decor_lnum != lnum) {
decor_providers_invoke_spell(wp, lnum - 1, col, lnum - 1, -1, decor_error);
@@ -1215,7 +1215,7 @@ static bool decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_lnum,
*decor_lnum = lnum;
}
decor_redraw_col(wp, col, col, false, &decor_state);
- return decor_state.spell == kTrue;
+ return decor_state.spell;
}
static inline bool can_syn_spell(win_T *wp, linenr_T lnum, int col)
@@ -1352,9 +1352,18 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att
: p - buf) > wp->w_cursor.col)) {
col = (colnr_T)(p - buf);
- bool can_spell = (!has_syntax && (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) == 0)
- || decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error)
- || (has_syntax && can_syn_spell(wp, lnum, col));
+ bool no_plain_buffer = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) != 0;
+ bool can_spell = !no_plain_buffer;
+ switch (decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error)) {
+ case kTrue:
+ can_spell = true; break;
+ case kFalse:
+ can_spell = false; break;
+ case kNone:
+ if (has_syntax) {
+ can_spell = can_syn_spell(wp, lnum, col);
+ }
+ }
if (!can_spell) {
attr = HLF_COUNT;