]> git.lyx.org Git - features.git/commitdiff
* fix for http://bugzilla.lyx.org/show_bug.cgi?id=2556
authorStefan Schimanski <sts@lyx.org>
Sun, 9 Mar 2008 23:43:05 +0000 (23:43 +0000)
committerStefan Schimanski <sts@lyx.org>
Sun, 9 Mar 2008 23:43:05 +0000 (23:43 +0000)
  "not possible to delete a label of a formula":

  Press forward delete at the end of a row and the label is deleted.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23610 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathHull.cpp

index 63065c2fb955fdd421fdacd6384d8086ed95239a..47615db07da7a03c5e09af815007feeecdb759a4 100644 (file)
@@ -26,6 +26,7 @@
 #include "InsetMathRef.h"
 
 #include "Buffer.h"
+#include "buffer_funcs.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "CutAndPaste.h"
@@ -492,7 +493,12 @@ void InsetMathHull::label(row_type row, docstring const & label)
 {
        //lyxerr << "setting label '" << label << "' for row " << row << endl;
        if (label_[row]) {
-               label_[row]->updateCommand(label);
+               if (label.empty()) {
+                       delete label_[row];
+                       nonum_[row] = true;
+                       label_[row] = dummy_pointer;
+               } else
+                       label_[row]->updateCommand(label);
                return;
        }
        InsetCommandParams p(LABEL_CODE);
@@ -1175,6 +1181,19 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
+       case LFUN_WORD_DELETE_FORWARD:
+       case LFUN_CHAR_DELETE_FORWARD:
+               if (col(cur.idx()) + 1 == ncols()
+                   && cur.pos() == cur.lastpos()
+                   && !label(row(cur.idx())).empty()) {
+                       cur.recordUndoInset();
+                       label(row(cur.idx()), docstring());
+               } else {
+                       InsetMathGrid::doDispatch(cur, cmd);
+                       return;
+               }
+               break;
+
        case LFUN_INSET_INSERT: {
                //lyxerr << "arg: " << to_utf8(cmd.argument()) << endl;
                // FIXME: this should be cleaned up to use InsetLabel methods directly.