summaryrefslogtreecommitdiffstats
path: root/src/drawscreen.c
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-05-27 22:22:10 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-27 22:22:10 +0100
commit30805a1aba0067cf0087f9a0e5c184562433e2e7 (patch)
treefb230c3a843711b3cb0369ef275f3377a8154c09 /src/drawscreen.c
parent1ba0b9e36f36926a7675b31efeda7d3e495c9157 (diff)
patch 9.0.1585: weird use of static variables for spell checkingv9.0.1585
Problem: Weird use of static variables for spell checking. Solution: Move the variables to a structure and pass them from win_update() to win_line(). (Luuk van Baal, closes #12448)
Diffstat (limited to 'src/drawscreen.c')
-rw-r--r--src/drawscreen.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 0912d7a156..9676f1b0f0 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -2191,11 +2191,25 @@ win_update(win_T *wp)
redraw_win_toolbar(wp);
#endif
+ lnum = wp->w_topline; // first line shown in window
+
+ spellvars_T spv;
+#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)
+ {
+ 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
+
// Update all the window rows.
idx = 0; // first entry in w_lines[].wl_size
row = 0;
srow = 0;
- lnum = wp->w_topline; // first line shown in window
for (;;)
{
// stop updating when reached the end of the window (check for _past_
@@ -2450,11 +2464,20 @@ win_update(win_T *wp)
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 = lnum + fold_count;
+ wp->w_lines[idx].wl_lastlnum = lnume;
# 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;
+ }
+# endif
}
else
#endif
@@ -2487,7 +2510,7 @@ win_update(win_T *wp)
#endif
// Display one line.
- row = win_line(wp, lnum, srow, wp->w_height, mod_top, FALSE);
+ row = win_line(wp, lnum, srow, wp->w_height, FALSE, &spv);
#ifdef FEAT_FOLDING
wp->w_lines[idx].wl_folded = FALSE;
@@ -2534,7 +2557,7 @@ win_update(win_T *wp)
fold_line(wp, fold_count, &win_foldinfo, lnum, row);
else
#endif
- (void)win_line(wp, lnum, srow, wp->w_height, mod_top, TRUE);
+ (void)win_line(wp, lnum, srow, wp->w_height, TRUE, &spv);
}
// This line does not need to be drawn, advance to the next one.