commit 93444892c504fdd7b8fdfbc7f2bf67f9b250eb82
Author: Thibaut Cuvelier <tcuvel...@lyx.org>
Date:   Mon Mar 11 01:07:25 2024 +0100

    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.
---
 src/mathed/InsetMathDelim.cpp | 12 ++++++++++--
 src/mathed/InsetMathDelim.h   |  6 ++++++
 src/mathed/MathExtern.cpp     |  4 ++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 486ed97580..78d26fceea 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -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;
 }
diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h
index cad8da49de..3d8bd2ce36 100644
--- a/src/mathed/InsetMathDelim.h
+++ b/src/mathed/InsetMathDelim.h
@@ -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
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 22124cc13d..d101904e83 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -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));
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to