]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathMacro.cpp
Avoid spurious requirements
[features.git] / src / mathed / InsetMathMacro.cpp
index 144318130ae52bddf49208f234c6b78e2bd5f37d..5743dd0e452b2a12311d51b8a512a9d285f4f1f5 100644 (file)
@@ -206,7 +206,7 @@ public:
                  expanded_(buf), definition_(buf), attachedArgsNum_(0),
                  optionals_(0), nextFoldMode_(true), macroBackup_(buf),
                  macro_(0), needsUpdate_(false), isUpdating_(false),
-                 appetite_(9), nesting_(0)
+                 appetite_(9), nesting_(0), limits_(AUTO_LIMITS)
        {
        }
        /// Update the pointers to our owner of all expanded macros.
@@ -248,6 +248,8 @@ public:
        size_t appetite_;
        /// Level of nesting in macros (including this one)
        int nesting_;
+       ///
+       Limits limits_;
 };
 
 
@@ -371,6 +373,7 @@ bool InsetMathMacro::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
        return has_contents;
 }
 
+
 /// Whether the inset allows \(no)limits
 bool InsetMathMacro::allowsLimitsChange() const
 {
@@ -403,6 +406,18 @@ Limits InsetMathMacro::defaultLimits() const
 }
 
 
+Limits InsetMathMacro::limits() const
+{
+       return d->limits_;
+}
+
+
+void InsetMathMacro::limits(Limits lim)
+{
+       d->limits_ = lim;
+}
+
+
 void InsetMathMacro::beforeMetrics() const
 {
        d->macro_->lock();
@@ -952,7 +967,16 @@ void InsetMathMacro::validate(LaTeXFeatures & features) const
 
        // validate the cells and the definition
        if (displayMode() == DISPLAY_NORMAL) {
-               d->definition_.validate(features);
+               // Don't update requirements if the macro comes from
+               // the symbols file and has not been redefined.
+               MathWordList const & words = mathedWordList();
+               MathWordList::const_iterator it = words.find(name());
+               MacroNameSet macros;
+               buffer().listMacroNames(macros);
+               if (it == words.end() || it->second.inset != "macro"
+                   || macros.find(name()) != macros.end()) {
+                       d->definition_.validate(features);
+               }
                InsetMathNest::validate(features);
        }
 }