Subject: bug#53773: 27.2; Flyspell delays region overlay update when the region is overwritten

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 03 Aug 2022 13:17:31 +0200

Andrea Greselin <[email-masked]> writes:

> Issuing a ‘(deactivate-mark)’ right before the line
>
>   (and (not unread-command-events)
>
> solves the problem but I don't know if it has any unwanted side
> effects or if it's a good way to go about it. By the way this bug
> also affects Emacs 28.1.

So the proposed change is the patch below, but I'm not really familiar
with this code.  Anybody have any comments?

diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 2c5e30fecd..883137d5bd 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -856,6 +856,7 @@ flyspell-check-word-p
        ((get this-command 'flyspell-delayed)
 	;; The current command is not delayed, that
 	;; is that we must check the word now.
+        (deactivate-mark)
 	(and (not unread-command-events)
 	     (sit-for flyspell-delay)))
        (t t)))