aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/drawscreen.c
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-05-28 00:12:56 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2023-06-01 14:30:15 +0200
commit316c8770348264f64deea34359cb5bdff6856ed8 (patch)
tree5173ab3a196514408a1cc154333f1cb912bb009a /src/nvim/drawscreen.c
parentb46f61ac050e6eb530ceb4d4b510b612596427c5 (diff)
downloadrneovim-316c8770348264f64deea34359cb5bdff6856ed8.tar.gz
rneovim-316c8770348264f64deea34359cb5bdff6856ed8.tar.bz2
rneovim-316c8770348264f64deea34359cb5bdff6856ed8.zip
vim-patch:9.0.1585: weird use of static variables for spell checking
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 vim/vim#12448) https://github.com/vim/vim/commit/30805a1aba0067cf0087f9a0e5c184562433e2e7
Diffstat (limited to 'src/nvim/drawscreen.c')
-rw-r--r--src/nvim/drawscreen.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 4f79ba87af..5e8481cd29 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -95,6 +95,7 @@
#include "nvim/profile.h"
#include "nvim/regexp.h"
#include "nvim/search.h"
+#include "nvim/spell.h"
#include "nvim/state.h"
#include "nvim/statusline.h"
#include "nvim/syntax.h"
@@ -1991,11 +1992,20 @@ static void win_update(win_T *wp, DecorProviders *providers)
win_check_ns_hl(wp);
+ spellvars_T spv = { 0 };
+ linenr_T lnum = wp->w_topline; // first line shown in window
+ // Initialize spell related variables for the first drawn line.
+ 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;
+ }
+
// Update all the window rows.
int idx = 0; // first entry in w_lines[].wl_size
int row = 0; // current window row to display
int srow = 0; // starting row of the current line
- linenr_T lnum = wp->w_topline; // first line shown in window
bool eof = false; // if true, we hit the end of the file
bool didline = false; // if true, we finished the last line
@@ -2223,7 +2233,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
// Display one line
row = win_line(wp, lnum, srow, foldinfo.fi_lines ? srow : wp->w_grid.rows,
- mod_top, false, foldinfo, &line_providers, &provider_err);
+ false, &spv, foldinfo, &line_providers, &provider_err);
if (foldinfo.fi_lines == 0) {
wp->w_lines[idx].wl_folded = false;
@@ -2232,8 +2242,15 @@ static void win_update(win_T *wp, DecorProviders *providers)
syntax_last_parsed = lnum;
} else {
foldinfo.fi_lines--;
+ linenr_T lnume = lnum + foldinfo.fi_lines;
wp->w_lines[idx].wl_folded = true;
- wp->w_lines[idx].wl_lastlnum = lnum + foldinfo.fi_lines;
+ wp->w_lines[idx].wl_lastlnum = lnume;
+
+ // 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;
+ }
did_update = DID_FOLD;
}
}
@@ -2260,7 +2277,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
// text doesn't need to be drawn, but the number column does.
foldinfo_T info = wp->w_p_cul && lnum == wp->w_cursor.lnum ?
cursorline_fi : fold_info(wp, lnum);
- (void)win_line(wp, lnum, srow, wp->w_grid.rows, mod_top, true,
+ (void)win_line(wp, lnum, srow, wp->w_grid.rows, true, &spv,
info, &line_providers, &provider_err);
}
@@ -2358,7 +2375,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
// for ml_line_count+1 and only draw filler lines
foldinfo_T info = { 0 };
row = win_line(wp, wp->w_botline, row, wp->w_grid.rows,
- mod_top, false, info, &line_providers, &provider_err);
+ false, &spv, info, &line_providers, &provider_err);
}
} else if (dollar_vcol == -1) {
wp->w_botline = lnum;