patch 9.0.1595: line pointer becomes invalid when using spell checking
Problem: Line pointer becomes invalid when using spell checking.
Solution: Call ml_get() at the right places. (Luuk van Baal, closes #12456)
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 9676f1b..86fec15 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -2197,12 +2197,10 @@
#ifdef FEAT_SPELL
// Initialize spell related variables for the first drawn line.
CLEAR_FIELD(spv);
- spv.spv_has_spell = spell_check_window(wp);
- if (spv.spv_has_spell)
+ if (spell_check_window(wp))
{
+ spv.spv_has_spell = TRUE;
spv.spv_unchanged = mod_top == 0;
- spv.spv_capcol_lnum = mod_top ? mod_top : lnum;
- spv.spv_cap_col = check_need_cap(wp, spv.spv_capcol_lnum, 0) ? 0 : - 1;
}
#endif
@@ -2464,19 +2462,13 @@
fold_line(wp, fold_count, &win_foldinfo, lnum, row);
++row;
--fold_count;
- linenr_T lnume = lnum + fold_count;
wp->w_lines[idx].wl_folded = TRUE;
- wp->w_lines[idx].wl_lastlnum = lnume;
+ wp->w_lines[idx].wl_lastlnum = lnum + fold_count;
# ifdef FEAT_SYN_HL
did_update = DID_FOLD;
# endif
# ifdef FEAT_SPELL
- // Check if the line after this fold requires a capital.
- if (spv.spv_has_spell && check_need_cap(wp, lnume + 1, 0))
- {
- spv.spv_cap_col = 0;
- spv.spv_capcol_lnum = lnume + 1;
- }
+ spv.spv_capcol_lnum = 0;
# endif
}
else
@@ -2572,6 +2564,9 @@
#ifdef FEAT_SYN_HL
did_update = DID_NONE;
#endif
+#ifdef FEAT_SPELL
+ spv.spv_capcol_lnum = 0;
+#endif
}
if (lnum > buf->b_ml.ml_line_count)