refactor(drawscreen): avoid spell check on folded or filler lines

This commit is contained in:
zeertzjq
2023-06-01 20:49:31 +08:00
parent ac1ad9651e
commit 51fd328184
2 changed files with 12 additions and 9 deletions

View File

@@ -1403,16 +1403,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
line = ml_get_buf(wp->w_buffer, lnum + 1, false); line = ml_get_buf(wp->w_buffer, lnum + 1, false);
spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
} }
line = end_fill ? "" : ml_get_buf(wp->w_buffer, lnum, false); assert(!end_fill);
line = ml_get_buf(wp->w_buffer, lnum, false);
// If current line is empty, check first word in next line for capital. // If current line is empty, check first word in next line for capital.
ptr = skipwhite(line); ptr = skipwhite(line);
if (*ptr == NUL) { if (*ptr == NUL) {
spv->spv_cap_col = 0; spv->spv_cap_col = 0;
spv->spv_capcol_lnum = lnum + 1; spv->spv_capcol_lnum = lnum + 1;
} } else if (spv->spv_cap_col == 0) {
// For checking first word with a capital skip white space. // For checking first word with a capital skip white space.
else if (spv->spv_cap_col == 0) {
spv->spv_cap_col = (int)(ptr - line); spv->spv_cap_col = (int)(ptr - line);
} }

View File

@@ -2230,8 +2230,10 @@ static void win_update(win_T *wp, DecorProviders *providers)
} }
// Display one line // Display one line
row = win_line(wp, lnum, srow, foldinfo.fi_lines ? srow : wp->w_grid.rows, spellvars_T zero_spv = { 0 };
false, &spv, foldinfo, &line_providers, &provider_err); row = win_line(wp, lnum, srow, foldinfo.fi_lines ? srow : wp->w_grid.rows, false,
foldinfo.fi_lines ? &zero_spv : &spv,
foldinfo, &line_providers, &provider_err);
if (foldinfo.fi_lines == 0) { if (foldinfo.fi_lines == 0) {
wp->w_lines[idx].wl_folded = false; wp->w_lines[idx].wl_folded = false;
@@ -2366,9 +2368,10 @@ static void win_update(win_T *wp, DecorProviders *providers)
if (j > 0 && !wp->w_botfill && row < wp->w_grid.rows) { if (j > 0 && !wp->w_botfill && row < wp->w_grid.rows) {
// Display filler text below last line. win_line() will check // Display filler text below last line. win_line() will check
// for ml_line_count+1 and only draw filler lines // for ml_line_count+1 and only draw filler lines
foldinfo_T info = { 0 }; spellvars_T zero_spv = { 0 };
row = win_line(wp, wp->w_botline, row, wp->w_grid.rows, foldinfo_T zero_foldinfo = { 0 };
false, &spv, info, &line_providers, &provider_err); row = win_line(wp, wp->w_botline, row, wp->w_grid.rows, false, &zero_spv,
zero_foldinfo, &line_providers, &provider_err);
} }
} else if (dollar_vcol == -1) { } else if (dollar_vcol == -1) {
wp->w_botline = lnum; wp->w_botline = lnum;