X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=d5c1051080f85566edc0938071a51a744abfd385;hb=371ed5aff5cd0de3bb0e7ba1e8265780137cd8c4;hp=191c291ce51f1a84e3b5f70aba390ca3aa93d8d3;hpb=040f3431e7a2350806594319704ff97a0284e9c1;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 191c291ce5..d5c1051080 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -182,12 +182,14 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind) static bool doInsertInset(Cursor & cur, Text * text, FuncRequest const & cmd, bool edit, bool pastesel) { - Inset * inset = createInset(cur.bv().buffer(), cmd); + Buffer & buffer = cur.bv().buffer(); + BufferParams const & bparams = buffer.params(); + Inset * inset = createInset(buffer, cmd); if (!inset) return false; if (InsetCollapsable * ci = inset->asInsetCollapsable()) - ci->setLayout(cur.bv().buffer().params()); + ci->setLayout(bparams); cur.recordUndo(); if (cmd.action == LFUN_INDEX_INSERT) { @@ -216,23 +218,21 @@ static bool doInsertInset(Cursor & cur, Text * text, 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 = insetText->useEmptyLayout() ? - cur.buffer().params().getTextClass().emptyLayout() : - 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); - } + // reset first par to default + LayoutPtr const layout = insetText->useEmptyLayout() + ? bparams.getTextClass().emptyLayout() + : bparams.getTextClass().defaultLayout(); + cur.text()->paragraphs().begin()->layout(layout); + cur.pos() = 0; + cur.pit() = 0; + // Merge multiple paragraphs -- hack + while (cur.lastpit() > 0) + mergeParagraph(bparams, cur.text()->paragraphs(), 0); } else { // reset surrounding par to default - docstring const layoutname = insetText->useEmptyLayout() ? - cur.buffer().params().getTextClass().emptyLayoutName() : - cur.buffer().params().getTextClass().defaultLayoutName(); + docstring const layoutname = insetText->useEmptyLayout() + ? bparams.getTextClass().emptyLayoutName() + : bparams.getTextClass().defaultLayoutName(); cur.leaveInset(*inset); text->setLayout(cur, layoutname); } @@ -1354,13 +1354,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) #endif case LFUN_CAPTION_INSERT: case LFUN_FOOTNOTE_INSERT: - // Open the inset, and move the current selection - // inside it. - doInsertInset(cur, this, cmd, true, true); - cur.posForward(); - // These insets are numbered. - updateLabels(bv->buffer()); - break; case LFUN_NOTE_INSERT: case LFUN_FLEX_INSERT: case LFUN_BOX_INSERT: @@ -1371,10 +1364,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_MARGINALNOTE_INSERT: case LFUN_OPTIONAL_INSERT: case LFUN_ENVIRONMENT_INSERT: + case LFUN_INDEX_INSERT: // Open the inset, and move the current selection // inside it. doInsertInset(cur, this, cmd, true, true); cur.posForward(); + // Some insets are numbered, others are shown in the outline pane so + // let's update the labels and the toc backend. + updateLabels(bv->buffer()); break; case LFUN_TABULAR_INSERT: @@ -1434,11 +1431,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } - case LFUN_INDEX_INSERT: - doInsertInset(cur, this, cmd, true, true); - cur.posForward(); - break; - case LFUN_NOMENCL_INSERT: { FuncRequest cmd1 = cmd; if (cmd.argument().empty())