diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-31 18:57:36 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-31 18:57:36 +0100 |
commit | e84c773d42e8b6ef0f8ae9b6c7312e0fd47909af (patch) | |
tree | 451c2f6769fb90c496219d08413b146d154938cb /src/drawline.c | |
parent | 68ebcee0237d927dd5386073499162389d4d708a (diff) |
patch 9.0.1595: line pointer becomes invalid when using spell checkingv9.0.1595
Problem: Line pointer becomes invalid when using spell checking.
Solution: Call ml_get() at the right places. (Luuk van Baal, closes #12456)
Diffstat (limited to 'src/drawline.c')
-rw-r--r-- | src/drawline.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/drawline.c b/src/drawline.c index 3811060df1..2b15f9a3f3 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1449,9 +1449,6 @@ win_line( area_highlighting = TRUE; #endif - line = ml_get_buf(wp->w_buffer, lnum, FALSE); - ptr = line; - #ifdef FEAT_SPELL if (spv->spv_has_spell && !number_only) { @@ -1462,28 +1459,36 @@ win_line( // current line is valid. if (lnum == spv->spv_checked_lnum) cur_checked_col = spv->spv_checked_col; - if (lnum != spv->spv_capcol_lnum) + // Previous line was not spell checked, check for capital. This happens + // for the first line in an updated region or after a closed fold. + if (spv->spv_capcol_lnum == 0 && check_need_cap(wp, lnum, 0)) + spv->spv_cap_col = 0; + else if (lnum != spv->spv_capcol_lnum) spv->spv_cap_col = -1; spv->spv_checked_lnum = 0; - // For checking first word with a capital skip white space. - if (spv->spv_cap_col == 0) - spv->spv_cap_col = getwhitecols(line); + // Get the start of the next line, so that words that wrap to the + // next line are found too: "et<line-break>al.". + // Trick: skip a few chars for C/shell/Vim comments + nextline[SPWORDLEN] = NUL; + if (lnum < wp->w_buffer->b_ml.ml_line_count) + { + line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE); + spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); + } + line = ml_get_buf(wp->w_buffer, lnum, FALSE); + // If current line is empty, check first word in next line for capital. - else if (*skipwhite(line) == NUL) + ptr = skipwhite(line); + if (*ptr == NUL) { spv->spv_cap_col = 0; spv->spv_capcol_lnum = lnum + 1; } + // For checking first word with a capital skip white space. + else if (spv->spv_cap_col == 0) + spv->spv_cap_col = ptr - line; - - // Get the start of the next line, so that words that wrap to the - // next line are found too: "et<line-break>al.". - // Trick: skip a few chars for C/shell/Vim comments - nextline[SPWORDLEN] = NUL; - if (lnum < wp->w_buffer->b_ml.ml_line_count) - spell_cat_line(nextline + SPWORDLEN, - ml_get_buf(wp->w_buffer, lnum + 1, FALSE), SPWORDLEN); // Copy the end of the current line into nextline[]. if (nextline[SPWORDLEN] == NUL) { @@ -1514,6 +1519,9 @@ win_line( } #endif + line = ml_get_buf(wp->w_buffer, lnum, FALSE); + ptr = line; + if (wp->w_p_list) { if (wp->w_lcs_chars.space |