]> git.lyx.org Git - features.git/commitdiff
Memorise whether delims are extracted from MathExtern.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Mon, 11 Mar 2024 00:07:25 +0000 (01:07 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Mon, 11 Mar 2024 00:10:15 +0000 (01:10 +0100)
This patch is part of a series that aims at solving https://www.lyx.org/trac/ticket/12891. It should not change any output.

src/mathed/InsetMathDelim.cpp
src/mathed/InsetMathDelim.h
src/mathed/MathExtern.cpp

index 486ed97580d94a9233e5b2ff5a0b1e99f85021f7..78d26fceea3722a3e0b01bcbe826c02d03f83907 100644 (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;
 }
index cad8da49de71dd9a084b32b827ba487e9ee4a1f7..3d8bd2ce36f91d0a469e57ec6f1c1dcaa061c5b7 100644 (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
index 22124cc13d4a6e68888064167c83fe4c7e00a418..d101904e83f97e01162c09ccdc0168497fceb615 100644 (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));
 }