* text3.C (dispatch/LFUN_INSET_DISSOLVE): use recordUndoInset;

rewrite and simplify.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14792 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2006-08-17 20:32:32 +00:00
parent d606047b0f
commit 3826a5c54f

View File

@ -79,6 +79,7 @@ using lyx::pos_type;
using lyx::cap::copySelection; using lyx::cap::copySelection;
using lyx::cap::cutSelection; using lyx::cap::cutSelection;
using lyx::cap::pasteParagraphList;
using lyx::cap::pasteSelection; using lyx::cap::pasteSelection;
using lyx::cap::replaceSelection; using lyx::cap::replaceSelection;
@ -709,39 +710,30 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
} }
case LFUN_INSET_DISSOLVE: { case LFUN_INSET_DISSOLVE: {
recordUndo(cur); recordUndoInset(cur);
cur.selHandle(false); cur.selHandle(false);
// save position // save position
lyx::pos_type spos = cur.pos(); lyx::pos_type spos = cur.pos();
lyx::pit_type spit = cur.pit(); lyx::pit_type spit = cur.pit();
bool content = false; ParagraphList plist;
if (cur.lastpit() != 0 || cur.lastpos() != 0) { if (cur.lastpit() != 0 || cur.lastpos() != 0)
setCursor(cur, 0, 0); plist = paragraphs();
cur.resetAnchor(); cur.popLeft();
cur.pit() = cur.lastpit(); // store cursor offset
cur.pos() = cur.lastpos(); if (spit == 0)
cur.setSelection(); spos += cur.pos();
copySelection(cur); spit += cur.pit();
content = true; cur.paragraph().erase(cur.pos());
} if (!plist.empty()) {
cur.popLeft(); Buffer * b = bv->buffer();
cur.resetAnchor(); pasteParagraphList(cur, plist, b->params().textclass,
// store cursor offset b->errorList("Paste"));
if (spit == 0)
spos += cur.pos();
spit += cur.pit();
cur.pos()++;
cur.setSelection();
if (content) {
lyx::cap::replaceSelection(cur);
pasteSelection(cur, bv->buffer()->errorList("Paste"), 0);
cur.clearSelection();
// restore position // restore position
cur.pit() = std::min(cur.lastpit(), spit); cur.pit() = std::min(cur.lastpit(), spit);
cur.pos() = std::min(cur.lastpos(), spos); cur.pos() = std::min(cur.lastpos(), spos);
cur.resetAnchor(); }
} else cur.clearSelection();
cutSelection(cur, false, false); cur.resetAnchor();
needsUpdate = true; needsUpdate = true;
break; break;
} }