When inserting text character in mathed, group in same \text when possible.

When inserting € in a math cell, it is put in a text inset and the
cursor leaves the inset. However, inserting ¤ then leads to
\text{€}\text{¤}.

Therefore, try to see if there is a previous \text inset that can be
recycled and insert the new inset there in this case, leading to
\text{€¤}.

Fixes bug #11979.
This commit is contained in:
Jean-Marc Lasgouttes 2021-11-28 14:33:45 +01:00
parent e522c5444e
commit 5eecfa3e04

View File

@ -1903,10 +1903,16 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
return true;
}
if (currentMode() == InsetMath::MATH_MODE && Encodings::isUnicodeTextOnly(c)) {
MathAtom at = createInsetMath("text", buf);
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
cur.insert(at);
cur.posForward();
MathAtom const atom(new InsetMathChar(c));
if (cur.prevInset() && cur.prevInset()->asInsetMath()->name() == "text") {
// reuse existing \text inset
cur.prevInset()->asInsetMath()->cell(0).push_back(atom);
} else {
MathAtom at = createInsetMath("text", buf);
at.nucleus()->cell(0).push_back(atom);
cur.insert(at);
cur.posForward();
}
return true;
}
} else {