(I checked that this bug predates my recent patches, including that
for bug#62445.)

Steps to reproduce: create test.tex with contents

--8<---------------cut here---------------start------------->8---
\documentclass{amsart}
\begin{document}
$\mathbf{U}(\mathbb{A}) \mathbf{A}(\mathbb{Q}) \backslash
\mathbf{G}(\mathbb{A})$ and $\mathbf{G}(\mathbb{Q}) \backslash
\mathbf{G}(\mathbb{A})$
\end{document}
--8<---------------cut here---------------end--------------->8---

and run preview-buffer (C-c C-p C-b).  Then overlay2 is totally messed up.

This is the example I encountered in the wild, and turns out to be
near-minimal.  The essential feature is that the ends of two
environments on the same line have long common suffixes.

My best attempt at a fix is in the attached patch, with justification below.

Here's the relevant part of _region_.log, which contains "before" and
"after" strings that aim to specify four positions on a line,
corresponding to the starts and ends of the two math environments:

--8<---------------cut here---------------start------------->8---
./_region_.tex:6: Preview: Snippet 1 started.
<-><->

l.6 $
     \mathbf{U}(\mathbb{A}) \mathbf{A}(\mathbb{Q}) \backslash \mathbf{G}(\ma...
Not a real error.

Preview: Tightpage -32891 -32891 32891 32891
./_region_.tex:6: Preview: Snippet 1 ended.(491520+163840x5055372).
<-><->

l.6 ...thbb{Q}) \backslash \mathbf{G}(\mathbb{A})$
                                                    and $\mathbf{G}(\mathbb{Q...
Not a real error.

[1]
./_region_.tex:6: Preview: Snippet 2 started.
<-><->

l.6 ...}) \backslash \mathbf{G}(\mathbb{A})$ and $
                                                  \mathbf{G}(\mathbb{Q}) \ba...
Not a real error.

./_region_.tex:6: Preview: Snippet 2 ended.(491520+163840x3515277).
<-><->

l.6 ...thbb{Q}) \backslash \mathbf{G}(\mathbb{A})$

Not a real error.
--8<---------------cut here---------------end--------------->8---

These positions are recovered by Emacs using calls to search-forward
that always start at the beginning of line.  The strings that should
identify the end of overlay2 also match the end of overlay1, hence the
bug.  The fix is to bump the point forward, before searching, by just
enough so that the search must go beyond any previous position
identified on the same line.

Attachment: 0001-Fix-preview-bug-involving-long-common-suffixes.patch
Description: Binary data

_______________________________________________
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex

Reply via email to