]> git.lyx.org Git - features.git/commitdiff
Fix getStatus for math-mutate and math-display
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 May 2016 07:24:55 +0000 (09:24 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 May 2016 16:02:24 +0000 (18:02 +0200)
Those two functions used two different hackish and buggy
implementation to know when the function is disabled. Replace that by
asking the containing inset whether it accepts inserting display math
inset.

Fixes bug #10033.
(cherry picked from commit de5630a1562054cb969b106e35f84bfe1e99002a)

src/mathed/InsetMathHull.cpp
status.22x

index efdeb8b05623f107660f6f511a3b081960d68c90..48792a81ae8b090a256dec55e0febac309498dfd 100644 (file)
@@ -1870,6 +1870,20 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
+namespace {
+
+bool allowDisplayMath(Cursor cur)
+{
+       LATTEST(cur.depth() > 1);
+       cur.pop();
+       FuncStatus status;
+       FuncRequest cmd(LFUN_MATH_DISPLAY);
+       return cur.getStatus(cmd, status) && status.enabled();
+}
+
+}
+
+
 bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & status) const
 {
@@ -1896,30 +1910,12 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
                status.setOnOff(type_ == ht);
                status.setEnabled(isMutable(ht) && isMutable(type_));
 
-               if (ht != hullSimple && status.enabled()) {
-                       Cursor tmpcur = cur;
-                       while (!tmpcur.empty()) {
-                               InsetCode code = tmpcur.inset().lyxCode();
-                               if (code == BOX_CODE) {
-                                       return true;
-                               } else if (code == TABULAR_CODE) {
-                                       FuncRequest tmpcmd(LFUN_MATH_DISPLAY);
-                                       if (tmpcur.getStatus(tmpcmd, status) && !status.enabled())
-                                               return true;
-                               }
-                               tmpcur.pop_back();
-                       }
-               }
+               if (ht != hullSimple && status.enabled())
+                       status.setEnabled(allowDisplayMath(cur));
                return true;
        }
        case LFUN_MATH_DISPLAY: {
-               bool enable = true;
-               if (cur.depth() > 1) {
-                       Inset const & in = cur[cur.depth()-2].inset();
-                       if (in.lyxCode() == SCRIPT_CODE)
-                               enable = display() != Inline;
-               }
-               status.setEnabled(enable);
+               status.setEnabled(display() != Inline || allowDisplayMath(cur));
                status.setOnOff(display() != Inline);
                return true;
        }
index 2607521125f4161c2e303200c0a8cf37eb636733..87f15fa13c7ed20cd9436f906add3a009bf491f9 100644 (file)
@@ -60,6 +60,9 @@ What's new
 - Display the correct column alignment and a better column spacing in AMS
   environments (bugs 1861, 9908).
 
+- Disable properly toggling math diplay in places where it is not
+  possible (bug 10033).
+
 - Fix horizontal scrolling feature when inside a collapsable inset
   with several paragraphs.