Subject: bug#48365: 13.0.11; Dollars in distinct comments trigger math mode highlighting in text in-between

From: jfbu <[email-masked]>
Date: Wed, 12 May 2021 09:22:50 +0200

Hello Tassilo=Keita-san
Le 12 mai 2021 à 08:49, Tassilo Horn <[email-masked]> a écrit :

> Ikumi Keita <[email-masked]> writes:
> 
> Hi Ikumi,
> 
>>> Would it make sense to apply these rules:
>> 
>>> 1. a $ in comments can never start math mode
>>> 2. but it can and will always stop math mode
>> 
>> That is a clean idea and, fortunately, easy to implment. Could you test
>> the attached patch?
> 
> I've committed a completely identical patch an hour ago with a diff just
> in the comment explaining what we are doing.  It's very encouraging when
> we both have the very same idea, so I think, it cannot be too wrong. :-)
> 
> Thanks,
> Tassilo

It is now revealed you are only one entity (perhaps an A.I. based
on quantum computing) pretending to be two humans only to
justify coverage of all time zones !

I have pulled the commit and it appears to work fine in my real-life
files (using doctex mode)

But I notice something weird when comparing effect on those two files

File A behaves as expected
% -*- mode: latex; -*-
%
\def\foo_with_underscore{}
\newcommand\foo{$}%
% a comment
A foo_bar^bar{$}
% a comment
B foo_bar^bar{$}
% a comment
C foo_bar^bar
$
%
%

File B seems to have a problem
% -*- mode: latex; -*-
%
\def\foo_with_underscore{}
\newcommand\foo{$}%$
% a comment
A foo_bar^bar{$}
% a comment
B foo_bar^bar{$}
% a comment
C foo_bar^bar
$
%
%

In case of file B, which differs only by an added %$ at end of the \newcommand line,
the \newcommand for example is not highlighted
and the B line changes colors without applying script style,
see screenshot

In case of file B I was expecting the B line to be styled in math mode,
it only has its color it seems,
and I was not expecting \newcommand\foo to lose its highlighting,

Perhaps this is a symptom of something else?

Best,
Jean-François