* 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.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
cur.setSelection();
copySelection(cur);
content = true;
}
cur.popLeft(); cur.popLeft();
cur.resetAnchor();
// store cursor offset // store cursor offset
if (spit == 0) if (spit == 0)
spos += cur.pos(); spos += cur.pos();
spit += cur.pit(); spit += cur.pit();
cur.pos()++; cur.paragraph().erase(cur.pos());
cur.setSelection(); if (!plist.empty()) {
if (content) { Buffer * b = bv->buffer();
lyx::cap::replaceSelection(cur); pasteParagraphList(cur, plist, b->params().textclass,
pasteSelection(cur, bv->buffer()->errorList("Paste"), 0); b->errorList("Paste"));
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.clearSelection();
cur.resetAnchor(); cur.resetAnchor();
} else
cutSelection(cur, false, false);
needsUpdate = true; needsUpdate = true;
break; break;
} }