Memorise whether delims are extracted from MathExtern.

This patch is part of a series that aims at solving https://www.lyx.org/trac/ticket/12891. It should not change any output.
This commit is contained in:
Thibaut Cuvelier 2024-03-11 01:07:25 +01:00
parent 1680eaf5f0
commit 93444892c5
3 changed files with 18 additions and 4 deletions

View File

@ -45,13 +45,21 @@ static docstring convertDelimToLatexName(docstring const & name)
InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l,
docstring const & r)
: InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
: InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), is_extracted_(false)
{}
InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring const & r,
MathData const & ar)
: InsetMathNest(buf, 1), left_(l), right_(r), dw_(0)
: InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), is_extracted_(false)
{
cell(0) = ar;
}
InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring const & r,
MathData const & ar, bool const is_extracted)
: InsetMathNest(buf, 1), left_(l), right_(r), dw_(0), is_extracted_(is_extracted)
{
cell(0) = ar;
}

View File

@ -27,6 +27,9 @@ public:
InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right,
MathData const &);
///
InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right,
MathData const &, bool const is_extracted);
///
InsetMathDelim * asDelimInset() override { return this; }
///
InsetMathDelim const * asDelimInset() const override { return this; }
@ -73,6 +76,9 @@ private:
Inset * clone() const override;
///
mutable int dw_;
/// Is it extracted by MathExtern routines? They try to extract as much
/// semantics from a raw LaTeX formula in terms of LyX insets.
bool const is_extracted_;
};
} // namespace lyx

View File

@ -500,7 +500,7 @@ bool testCloseParen(MathAtom const & at)
MathAtom replaceParenDelims(const MathData & ar)
{
return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
from_ascii("("), from_ascii(")"), ar));
from_ascii("("), from_ascii(")"), ar, true));
}
@ -519,7 +519,7 @@ bool testCloseBracket(MathAtom const & at)
MathAtom replaceBracketDelims(const MathData & ar)
{
return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
from_ascii("["), from_ascii("]"), ar));
from_ascii("["), from_ascii("]"), ar, true));
}