summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-25 20:58:30 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-25 20:58:30 +0100
commitee09fcc9b6cf24e02899461809da9a5148208ea5 (patch)
treeda98cebee25cc4d625d0276b44fbac9190d31341
parentb7e07dc1036b5b02870c72e872bbb248640ade7d (diff)
downloadvim-git-ee09fcc9b6cf24e02899461809da9a5148208ea5.tar.gz
patch 9.0.0590: after exiting Insert mode spelling not checked in next linev9.0.0590
Problem: After exiting Insert mode spelling is not checked in the next line. Solution: When spelling is enabled redraw the next line after exiting Insert mode in case the spell highlight needs updating.
-rw-r--r--src/drawline.c5
-rw-r--r--src/edit.c7
-rw-r--r--src/proto/spell.pro1
-rw-r--r--src/spell.c25
-rw-r--r--src/testdir/dumps/Test_spell_3.dump8
-rw-r--r--src/testdir/test_spell.vim4
-rw-r--r--src/version.c2
7 files changed, 40 insertions, 12 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 7e18ced3c..5413347b7 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1125,10 +1125,7 @@ win_line(
#endif
#ifdef FEAT_SPELL
- if (wp->w_p_spell
- && *wp->w_s->b_p_spl != NUL
- && wp->w_s->b_langp.ga_len > 0
- && *(char **)(wp->w_s->b_langp.ga_data) != NULL)
+ if (spell_check_window(wp))
{
// Prepare for spell checking.
has_spell = TRUE;
diff --git a/src/edit.c b/src/edit.c
index 0b7896476..ec3e8ff6c 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -3587,6 +3587,13 @@ ins_esc(
#ifdef FEAT_SPELL
check_spell_redraw();
+
+ // When text has been changed in this line, possibly the start of the next
+ // line may have SpellCap that should be removed or it needs to be
+ // displayed. Schedule the next line for redrawing just in case.
+ if (spell_check_window(curwin)
+ && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
+ redrawWinline(curwin, curwin->w_cursor.lnum + 1);
#endif
temp = curwin->w_cursor.col;
diff --git a/src/proto/spell.pro b/src/proto/spell.pro
index 4a3e85b14..55c8482cd 100644
--- a/src/proto/spell.pro
+++ b/src/proto/spell.pro
@@ -5,6 +5,7 @@ int can_compound(slang_T *slang, char_u *word, char_u *flags);
int match_compoundrule(slang_T *slang, char_u *compflags);
int valid_word_prefix(int totprefcnt, int arridx, int flags, char_u *word, slang_T *slang, int cond_req);
int spell_valid_case(int wordflags, int treeflags);
+int spell_check_window(win_T *wp);
int spell_move_to(win_T *wp, int dir, int allwords, int curline, hlf_T *attrp);
void spell_cat_line(char_u *buf, char_u *line, int maxlen);
char_u *spell_enc(void);
diff --git a/src/spell.c b/src/spell.c
index 08f627d0a..628814fe6 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -1238,18 +1238,27 @@ spell_valid_case(
}
/*
- * Return TRUE if spell checking is not enabled.
+ * Return TRUE if spell checking is enabled for "wp".
+ */
+ int
+spell_check_window(win_T *wp)
+{
+ return wp->w_p_spell
+ && *wp->w_s->b_p_spl != NUL
+ && wp->w_s->b_langp.ga_len > 0
+ && *(char **)(wp->w_s->b_langp.ga_data) != NULL;
+}
+
+/*
+ * Return TRUE and give an error if spell checking is not enabled.
*/
static int
no_spell_checking(win_T *wp)
{
- if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
- || wp->w_s->b_langp.ga_len == 0)
- {
- emsg(_(e_spell_checking_is_not_possible));
- return TRUE;
- }
- return FALSE;
+ if (spell_check_window(wp))
+ return FALSE;
+ emsg(_(e_spell_checking_is_not_possible));
+ return TRUE;
}
/*
diff --git a/src/testdir/dumps/Test_spell_3.dump b/src/testdir/dumps/Test_spell_3.dump
new file mode 100644
index 000000000..8dcd045b0
--- /dev/null
+++ b/src/testdir/dumps/Test_spell_3.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@2|T|h|i|s| |l|i|n|e| |h|a|s| |a| |s+0&#ffd7d7255|e|p|l@1| +0&#ffffff0|e|r@1|o|r|.| |a+0&#5fd7ff255|n|d| +0&#ffffff0|m|i|s@1|i|n|g| |c|a|p|s| |a|n|d| |t|r|a|i|l|i|n|g| |s|p|a|c|e|s|.| @5
+|a+0&#5fd7ff255|n|o|t|h|e|r| +0&#ffffff0|m|i|s@1|i|n|g| |c|a|p| |h|e|r|e|.| @49
+|N|o>t| @71
+|a|n|d| |h|e|r|e|.| @65
+@75
+|a+0&#5fd7ff255|n|d| +0&#ffffff0|h|e|r|e|.| @65
+|~+0#4040ff13&| @73
+| +0#0000000&@56|3|,|3| @10|A|l@1|
diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim
index 3ea9afff1..90c6d53ce 100644
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -983,6 +983,10 @@ func Test_spell_screendump_spellcap()
let buf = RunVimInTerminal('-S XtestSpellCap', {'rows': 8})
call VerifyScreenDump(buf, 'Test_spell_2', {})
+ " After adding word missing Cap in next line is updated
+ call term_sendkeys(buf, "3GANot\<Esc>")
+ call VerifyScreenDump(buf, 'Test_spell_3', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestSpellCap')
diff --git a/src/version.c b/src/version.c
index dedb6ccb2..0d7dadaf7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 590,
+/**/
589,
/**/
588,