Jean-Marc Lasgouttes wrote: > I think I see what you mean. OK, so let it return an InsetBase, but > rename the method to something like realInset().
The attached patch works for me. Jürgen
Index: dociterator.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v retrieving revision 1.32 diff -p -u -r1.32 dociterator.C --- dociterator.C 25 Oct 2005 09:14:11 -0000 1.32 +++ dociterator.C 24 Nov 2005 16:04:25 -0000 @@ -20,6 +20,7 @@ #include "mathed/math_data.h" #include "mathed/math_inset.h" +#include "insets/insettabular.h" #include <boost/assert.hpp> #include <boost/current_function.hpp> @@ -87,6 +88,18 @@ InsetBase const * DocIterator::prevInset if (inMathed()) return prevAtom().nucleus(); return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0; +} + + +InsetBase * DocIterator::realInset() const +{ + BOOST_ASSERT(inTexted()); + // if we are in a tabular, we need the cell + if (inset().lyxCode() == InsetBase::TABULAR_CODE) { + InsetTabular & tabular = static_cast<InsetTabular&>(inset()); + return tabular.cell(idx()).get(); + } + return &inset(); } Index: dociterator.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.h,v retrieving revision 1.24 diff -p -u -r1.24 dociterator.h --- dociterator.h 25 Oct 2005 09:14:11 -0000 1.24 +++ dociterator.h 24 Nov 2005 16:04:25 -0000 @@ -164,6 +164,8 @@ public: LyXText * text(); /// LyXText const * text() const; + /// the containing inset or the cell, respectively + InsetBase * realInset() const; /// InsetBase * innerInsetOfType(int code) const; /// Index: undo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v retrieving revision 1.68 diff -p -u -r1.68 undo.C --- undo.C 13 Oct 2005 17:20:30 -0000 1.68 +++ undo.C 24 Nov 2005 16:04:26 -0000 @@ -187,10 +187,10 @@ bool textUndoOrRedo(BufferView & bv, // this ugly stuff is needed until we get rid of the // inset_owner backpointer - ParagraphList::const_iterator pit = undo.pars.begin(); - ParagraphList::const_iterator end = undo.pars.end(); + ParagraphList::iterator pit = undo.pars.begin(); + ParagraphList::iterator const end = undo.pars.end(); for (; pit != end; ++pit) - const_cast<Paragraph &>(*pit).setInsetOwner(&dit.inset()); + pit->setInsetOwner(dit.realInset()); plist.insert(first, undo.pars.begin(), undo.pars.end()); }