From bd8cba506fe42c6a71e23eafc32ea9f5fc52c19f Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 9 Feb 2008 10:45:49 +0000 Subject: [PATCH] * doInsertInset(): return early. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22891 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text3.cpp | 66 ++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 23adba768b..85c29d058c 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -197,42 +197,44 @@ static bool doInsertInset(Cursor & cur, Text * text, inset->edit(cur, true); // Now put this into inset static_cast(inset)->text_.insertStringAsParagraphs(cur, ds); - } else { - bool gotsel = false; - if (cur.selection()) { - lyx::dispatch(FuncRequest(LFUN_CUT)); - gotsel = true; - } - text->insertInset(cur, inset); + return true; + } - if (edit) - inset->edit(cur, true); + bool gotsel = false; + if (cur.selection()) { + lyx::dispatch(FuncRequest(LFUN_CUT)); + gotsel = true; + } + text->insertInset(cur, inset); - if (gotsel && pastesel) { - lyx::dispatch(FuncRequest(LFUN_PASTE, "0")); - InsetText * insetText = dynamic_cast(inset); - if (insetText && !insetText->allowMultiPar() - || cur.lastpit() == 0) { - // reset first par to default - LayoutPtr const layout = - cur.buffer().params().getTextClass().defaultLayout(); - cur.text()->paragraphs().begin()->layout(layout); - cur.pos() = 0; - cur.pit() = 0; - // Merge multiple paragraphs -- hack - while (cur.lastpit() > 0) { - mergeParagraph(cur.buffer().params(), - cur.text()->paragraphs(), 0); - } - } else { - // reset surrounding par to default - docstring const layoutname = - cur.buffer().params().getTextClass().defaultLayoutName(); - cur.leaveInset(*inset); - text->setLayout(cur, layoutname); + if (edit) + inset->edit(cur, true); + + if (!gotsel || !pastesel) + return true; + + lyx::dispatch(FuncRequest(LFUN_PASTE, "0")); + InsetText * insetText = dynamic_cast(inset); + if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) { + // reset first par to default + LayoutPtr const layout = + cur.buffer().params().getTextClass().defaultLayout(); + cur.text()->paragraphs().begin()->layout(layout); + cur.pos() = 0; + cur.pit() = 0; + // Merge multiple paragraphs -- hack + while (cur.lastpit() > 0) { + mergeParagraph(cur.buffer().params(), + cur.text()->paragraphs(), 0); } - } + } else { + // reset surrounding par to default + docstring const layoutname = + cur.buffer().params().getTextClass().defaultLayoutName(); + cur.leaveInset(*inset); + text->setLayout(cur, layoutname); } + return true; } -- 2.39.2