From bff67c9fbe8c174dae8952a565a110930dc4fc58 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 19:50:01 +0200 Subject: vim-patch:9.0.0175: spell checking for capital not working with trailing space Problem: Spell checking for capital not working with trailing space. Solution: Do not calculate cap_col at the end of the line. (Christian Brabandt, closes vim/vim#10870, issue vim/vim#10838) https://github.com/vim/vim/commit/afa23d1b99692e3c726eb694933ab348b442a1e4 Co-authored-by: Christian Brabandt --- src/nvim/drawline.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 927b1247be..a49b2ac6d6 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2188,12 +2188,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, v = (ptr - line); if (has_spell && v >= word_end && v > cur_checked_col) { spell_attr = 0; - if (c != 0 && ((!has_syntax && !no_plain_buffer) || can_spell)) { - char *prev_ptr; + char *prev_ptr = ptr - mb_l; + // do not calculate cap_col at the end of the line or when + // only white space is following + if (c != 0 && (*skipwhite(prev_ptr) != NUL) + && ((!has_syntax && !no_plain_buffer) || can_spell)) { char *p; - int len; hlf_T spell_hlf = HLF_COUNT; - prev_ptr = ptr - mb_l; v -= mb_l - 1; // Use nextline[] if possible, it has the start of the @@ -2206,7 +2207,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, cap_col -= (int)(prev_ptr - line); size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange); assert(tmplen <= INT_MAX); - len = (int)tmplen; + int len = (int)tmplen; word_end = (int)v + len; // In Insert mode only highlight a word that -- cgit