mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Fix math class code in InsetMathColor
The current code is too naïve and asserts on MC_UNKNOWN class. See discussion here: https://marc.info/?l=lyx-devel&m=161267112524889&w=2
This commit is contained in:
parent
983d327fe3
commit
c311451518
@ -98,12 +98,8 @@ void InsetMathColor::write(TeXMathStream & os) const
|
||||
{
|
||||
// We have to ensure correct spacing when the front and/or back
|
||||
// atoms are not ordinary ones (bug 11827).
|
||||
docstring const frontclass =
|
||||
!cell(0).empty() ? class_to_string(cell(0).front()->mathClass())
|
||||
: from_ascii("mathord");
|
||||
docstring const backclass =
|
||||
!cell(0).empty() ? class_to_string(cell(0).back()->mathClass())
|
||||
: from_ascii("mathord");
|
||||
docstring const frontclass = class_to_string(cell(0).firstMathClass());
|
||||
docstring const backclass = class_to_string(cell(0).lastMathClass());
|
||||
bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_);
|
||||
bool adjust_front = frontclass != "mathord" && adjchk;
|
||||
bool adjust_back = backclass != "mathord" && adjchk;
|
||||
|
@ -969,6 +969,17 @@ MathClass MathData::mathClass() const
|
||||
}
|
||||
|
||||
|
||||
MathClass MathData::firstMathClass() const
|
||||
{
|
||||
for (MathAtom const & at : *this) {
|
||||
MathClass mc = at->mathClass();
|
||||
if (mc != MC_UNKNOWN)
|
||||
return mc;
|
||||
}
|
||||
return MC_ORD;
|
||||
}
|
||||
|
||||
|
||||
MathClass MathData::lastMathClass() const
|
||||
{
|
||||
MathClass res = MC_ORD;
|
||||
|
@ -144,6 +144,8 @@ public:
|
||||
void drawT(TextPainter & pi, int x, int y) const;
|
||||
/// approximate mathclass of the data
|
||||
MathClass mathClass() const;
|
||||
/// math class of first interesting element
|
||||
MathClass firstMathClass() const;
|
||||
/// math class of last interesting element
|
||||
MathClass lastMathClass() const;
|
||||
/// is the cell in display style
|
||||
|
Loading…
Reference in New Issue
Block a user