From 28168bd4df9a568e79cdc57cb257743b7adb7c2a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 26 Mar 2002 12:38:59 +0000 Subject: [PATCH] work around for bug reported by Mario Morandini git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3838 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formulabase.C | 7 ++++--- src/mathed/math_cursor.C | 8 ++++++++ src/mathed/math_cursor.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 19ea21e686..22b6bba24f 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -667,11 +667,12 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, MathInset::idx_type idx = 0; MathGridInset * p = mathcursor ? mathcursor->enclosingGrid(idx) : 0; if (p) { + mathcursor->popToEnclosingGrid(); bv->lockedInsetStoreUndo(Undo::EDIT); - char al = arg.size() ? arg[0] : 'c'; + char align = arg.size() ? arg[0] : 'c'; switch (action) { - case LFUN_MATH_HALIGN: p->halign(al, p->col(idx)); break; - case LFUN_MATH_VALIGN: p->valign(al); break; + case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break; + case LFUN_MATH_VALIGN: p->valign(align); break; case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break; case LFUN_MATH_ROW_DELETE: p->delRow(p->row(idx)); break; case LFUN_MATH_COLUMN_INSERT: p->addCol(p->col(idx)); break; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 1a2842ad69..e9cdf182f5 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -897,12 +897,20 @@ MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const if (p) { idx = Cursor_[i].idx_; return p; + lyxerr << "found grid and idx: " << idx << "\n"; } } return 0; } +void MathCursor::popToEnclosingGrid() +{ + while (Cursor_.size() && !Cursor_.back().par_->asGridInset()) + Cursor_.pop_back(); +} + + void MathCursor::pullArg(bool goright) { dump("pullarg"); diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 4f4a19fd65..6d8748a203 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -106,6 +106,8 @@ public: MathInset * par() const; /// return the next enclosing grid inset and the cursor's index in it MathGridInset * enclosingGrid(idx_type &) const; + /// return the next enclosing grid inset and the cursor's index in it + void popToEnclosingGrid(); /// InsetFormulaBase * formula(); /// current offset in the current cell -- 2.39.2