]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
fix a crash when the inset containing the new word at cursor is deleted
[lyx.git] / src / mathed / MathMacro.cpp
index 6a232716dce29bbd1a8cce64d9e7a257f406c2ee..d96dc31b449623fbe62f5cd3352523d6b25f860b 100644 (file)
@@ -164,9 +164,12 @@ bool MathMacro::editMode(BufferView const * bv) const {
                        // look if there is no other macro in edit mode above
                        ++i;
                        for (; i != cur.depth(); ++i) {
-                               MathMacro const * macro = dynamic_cast<MathMacro const *>(&cur[i].inset());
-                               if (macro && macro->displayMode() == DISPLAY_NORMAL)
-                                       return false;
+                               InsetMath * im = cur[i].asInsetMath();
+                               if (im) {
+                                       MathMacro const * macro = im->asMacro();
+                                       if (macro && macro->displayMode() == DISPLAY_NORMAL)
+                                               return false;
+                               }
                        }
 
                        // ok, none found, I am the highest one
@@ -640,6 +643,7 @@ bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
                        inset_cursor.cell().erase(inset_cursor.pos());
                        inset_cursor.cell().insert(inset_cursor.pos(),
                                createInsetMath(unfolded_name, cur.buffer()));
+                       cur.resetAnchor();
                        cur.screenUpdateFlags(cur.result().screenUpdate() | Update::SinglePar);
                        return true;
                }