]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.C
BUG 686: delete empty math box with delete/backspace key
[lyx.git] / src / mathed / InsetMathNest.C
index 1596e95794817a1903d320aab7f5955a36ae9456..49867f7fe3ba1612c39b4dfde4b3f981f5adc91d 100644 (file)
@@ -52,7 +52,6 @@
 
 #include "frontends/Painter.h"
 #include "frontends/Selection.h"
-#include "frontends/nullpainter.h"
 
 #include "funcrequest.h"
 #include "lyxserver.h"
@@ -649,7 +648,11 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                        recordUndoInset(cur, Undo::ATOMIC);
                else
                        recordUndo(cur, Undo::ATOMIC);
-               cur.backspace();
+               // if the inset can not be removed from within, delete it
+               if (!cur.backspace()) {
+                       FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
+                       cur.bv().getLyXText()->dispatch(cur, cmd);
+               }
                break;
 
        case LFUN_WORD_DELETE_FORWARD:
@@ -659,7 +662,11 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                        recordUndoInset(cur, Undo::ATOMIC);
                else
                        recordUndo(cur, Undo::ATOMIC);
-               cur.erase();
+               // if the inset can not be removed from within, delete it
+               if (!cur.erase()) {
+                       FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
+                       cur.bv().getLyXText()->dispatch(cur, cmd);
+               }
                break;
 
        case LFUN_ESCAPE:
@@ -1404,11 +1411,7 @@ bool InsetMathNest::script(LCursor & cur, bool up,
                }
                --cur.pos();
                InsetMathScript * inset = cur.nextAtom().nucleus()->asScriptInset();
-               // special handling of {}-bases
-               // is this always correct?
-               if (inset->nuc().size() == 1
-                   && inset->nuc().back()->asBraceInset())
-                       inset->nuc() = inset->nuc().back()->asNestInset()->cell(0);
+               // See comment in MathParser.C for special handling of {}-bases
 
                cur.push(*inset);
                cur.idx() = 1;