From a22bf49a4e4408d51f554c86bfc169c779b1909a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 26 Jul 2002 07:39:13 +0000 Subject: [PATCH] fix nasty crash when selection anchor pointed to a deleted cell git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4791 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 12 ++++++------ src/mathed/math_cursor.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 09f2cf8492..964708eaee 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -52,7 +52,7 @@ #include #include -#define FILEDEBUG 0 +//#define FILEDEBUG 1 using std::endl; using std::min; @@ -173,7 +173,7 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const if (t->asScriptInset()) return false; - if (sel) { + if (!sel) { // we can't move into anything new during selection if (depth() == Anchor_.size()) return false; @@ -339,6 +339,7 @@ void MathCursor::markErase() void MathCursor::plainInsert(MathAtom const & t) { + dump("plainInsert"); array().insert(pos(), t); ++pos(); } @@ -436,7 +437,7 @@ void MathCursor::backspace() { autocorrect_ = false; if (pos() == 0) { - pullArg(false); + pullArg(); return; } @@ -814,7 +815,7 @@ void MathCursor::popToEnclosingHull() } -void MathCursor::pullArg(bool goright) +void MathCursor::pullArg() { dump("pullarg"); MathArray a = array(); @@ -835,8 +836,7 @@ void MathCursor::pullArg(bool goright) if (popLeft()) { plainErase(); array().insert(pos(), a); - if (goright) - pos() += a.size(); + Anchor_ = Cursor_; } else { formula()->mutateToText(); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 3fde675960..161b70e3b1 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -176,8 +176,6 @@ public: /// remove this as soon as LyXFunc::getStatus is "localized" string getLastCode() const { return "mathnormal"; } /// - void pullArg(bool goright); - /// bool isInside(MathInset const *) const; /// char valign() const; @@ -266,6 +264,8 @@ public: private: + /// injects content of a cell into parent + void pullArg(); /// moves cursor index one cell to the left bool idxLeft(); /// moves cursor index one cell to the right -- 2.39.2