From befe2da495bf24d651c81bb35fbcda5976f09077 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 28 Jun 2023 21:17:26 +0200 Subject: [PATCH] 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. --- src/mathed/InsetMathChar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 483bbb8403..d923d04dc0 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -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_); }