Subject: bug#56682: Fix the long lines font locking related slowdowns

From: Eli Zaretskii <[email-masked]>
Date: Fri, 29 Jul 2022 16:27:50 +0300

> Date: Fri, 29 Jul 2022 08:33:38 +0000
> From: Gregory Heytings <[email-masked]>
> cc: [email-masked], [email-masked], [email-masked], 
>     [email-masked]
> 
> Now done, and closing this bug.

Hmm...  I'm bothered by this code in handle_fontified_prop:

      if (it->narrowed_begv)
	Fnarrow_to_region (make_fixnum (it->narrowed_begv),
			   make_fixnum (it->narrowed_zv), Qt);

This narrows the buffer around window's point position (since this is
how narrowed_begv and narrowed_zv are computed), but the display
iterator can be called for position outside this range.  This is
unlikely to happen when the function is called as part of actual
redisplay of a window, but it can easily happen when the display code
is used by other primitives, for example vertical-motion or
pos-visible-in-window-p.  What happens then is that
fontification-functions are called with the argument POS that is
outside of the restriction, and that can cause errors.  (jit-lock
simply does nothing in that case, AFAICT.)

Is this intended?