Honor pending spaces in InsetMathChar::write

The InsetMathChar::write() method directly accesses the otexrowstream
underlying the TeXMathStream class for writing a character, thus
shortcircuiting the mechanism that allows to separate a macro from the
following material. It has to do so because directly writing a char_type
would cause printing its numerical value instead of the corresponding
unicode character in systems where char_type is typedef'd to uint32_t.

This problem has been uncovered by [7441172d/lyxgit] because each atom
of a mathed cell was being separately written to the output instead of
using the lyx::write() method in MathExtern.cpp that simply converts
everything to a docstring. As InsetMathChar::write() is the only method
bypassing the TeXMathStream machanism, it is simpler teaching it to
honor the pending space instead of modifying the code in InsetMathColor.

This commit amends 7441172d.
This commit is contained in:
Enrico Forestieri 2023-06-28 21:17:26 +02:00
parent 889dac7def
commit befe2da495

View File

@ -195,6 +195,11 @@ void InsetMathChar::drawT(TextPainter & pain, int x, int y) const
void InsetMathChar::write(TeXMathStream & os) const
{
if (os.latex() && os.pendingSpace()) {
if (isAlphaASCII(char_))
os.os() << ' ';
os.pendingSpace(false);
}
os.os().put(char_);
}