Subject: bug#56815: 29.0.50; Isearch lazy-highlight highlights too much when truncate-lines is in effect

From: Juri Linkov <[email-masked]>
Date: Thu, 28 Jul 2022 23:08:23 +0300

> To reproduce, visit any file with very long lines, turn on
> truncate-lines, and invoke Isearch. after typing some search string
> for which there are matches in the buffer, Isearch will highlight many
> matches that are not visible in the window.  In an extreme case where
> a file has a single very long line, all the matches in the buffer will
> be highlighted.  This both takes long time, and slows down many
> display-related commands, because the large number of overlays created
> for the highlighting slows down redisplay.
>
> This happens because isearch.el uses window-end as the limit beyond
> which to stop highlighting, but that is a poor indicator of visibility
> in buffers under truncate-lines.
>
> If isearch.el cannot find a better criterion for stopping highlighting
> beyond some buffer position, it should at least use some reasonable
> fixed (or customizable) limit.  Another possibility is to turn off
> lazy-highlight by default when truncate-lines is turned on.
>
> This issue is related to poor Emacs performance in buffers with very
> long lines, and its fix is essential for making Emacs more usable with
> such buffers.

I didn't follow the new design of long lines handling.
Does it just narrow each long truncated line?
When narrowing is in effect then lazy-highlight
should already do the right thing since it can't go
outside of the narrowed regions.