]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulabase.C
Fix.
[lyx.git] / src / mathed / formulabase.C
index be8ee3c160fb0af4e107ff408edb34f15fe99faa..1ab3bf9c90d704652d9e7bc204718d22ab788c53 100644 (file)
@@ -18,9 +18,6 @@
 #include "Lsstream.h"
 #include "support/LAssert.h"
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "formula.h"
 #include "formulamacro.h"
@@ -420,6 +417,9 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        //      << " y: '" << cmd.y
        //      << "' button: " << cmd.button() << endl;
 
+       // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
+       bool remove_inset = false;
+
        switch (cmd.action) {
                case LFUN_MOUSE_PRESS:
                        return lfunMousePress(cmd);
@@ -536,7 +536,7 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_PRIOR:
        case LFUN_BEGINNINGBUFSEL:
        case LFUN_BEGINNINGBUF:
-               result = FINISHED_UP;
+               result = FINISHED;
                updateLocal(bv, false);
                break;
 
@@ -544,7 +544,7 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_NEXT:
        case LFUN_ENDBUFSEL:
        case LFUN_ENDBUF:
-               result = FINISHED_DOWN;
+               result = FINISHED_RIGHT;
                updateLocal(bv, false);
                break;
 
@@ -560,16 +560,26 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
 
        case LFUN_DELETE_WORD_BACKWARD:
        case LFUN_BACKSPACE:
-               bv->lockedInsetStoreUndo(Undo::DELETE);
-               mathcursor->backspace();
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               if (mathcursor->backspace()) {
+                       result = DISPATCHED;
+               } else {
+                       result = FINISHED;
+                       remove_inset = true;
+               }
                updateLocal(bv, true);
                break;
 
        case LFUN_DELETE_WORD_FORWARD:
        case LFUN_DELETE:
-               bv->lockedInsetStoreUndo(Undo::DELETE);
-               mathcursor->erase();
-               bv->updateInset(this, true);
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               if (mathcursor->erase()) {
+                       result = DISPATCHED;
+               } else {
+                       result = FINISHED;
+                       remove_inset = true;
+               }
+               updateLocal(bv, true);
                break;
 
        //    case LFUN_GETXY:
@@ -829,6 +839,8 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        } else {
                releaseMathCursor(bv);
                bv->unlockInset(this);
+               if (remove_inset)
+                       bv->owner()->dispatch(FuncRequest(LFUN_DELETE));
        }
 
        return result;  // original version