- pars_.erase(pars_.begin() + old.pit());
-
- // Update cursor par offset if necessary.
- // Some 'iterator registration' would be nice that takes care of
- // such events. Maybe even signal/slot?
- if (cur.pit() > old.pit())
- --cur.pit();
-#ifdef WITH_WARNINGS
-#warning DEPM, look here
-#endif
-// if (cur.anchor().pit() > old.pit())
-// --cur.anchor().pit();
-
- if (selection_position_was_oldcursor_position) {
- // correct selection
- cur.resetAnchor();
+ recordUndo(old, Undo::ATOMIC,
+ max(old.pit() - 1, pit_type(0)),
+ min(old.pit() + 1, old.lastpit()));
+ ParagraphList & plist = old.text()->paragraphs();
+ plist.erase(boost::next(plist.begin(), old.pit()));
+
+ // see #warning above
+ if (cur.depth() >= old.depth()) {
+ CursorSlice & curslice = cur[old.depth() - 1];
+ if (&curslice.inset() == &old.inset()
+ && curslice.pit() > old.pit()) {
+ --curslice.pit();
+ // since a paragraph has been deleted, all the
+ // insets after `old' have been copied and
+ // their address has changed. Therefore we
+ // need to `regenerate' cur. (JMarc)
+ cur.updateInsets(&(cur.bottom().inset()));
+ cur.resetAnchor();
+ }