X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=f234c7cb7d027c95fd979b3cd281c0709092493a;hb=bed546d6f6aab7c32ef51d61edd120e18089da53;hp=f8ef5ff49c804816d2c08e81fcd91e6342796416;hpb=532765c03a22285d44f52a46d6907a738a67614d;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index f8ef5ff49c..f234c7cb7d 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1595,11 +1595,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } DocumentClass const & tclass = bv->buffer().params().documentClass(); + bool inautoarg = false; for (auto const & la_pair : tclass[layout].args()) { Layout::latexarg const & arg = la_pair.second; if (arg.autoinsert) { + // If we had already inserted an arg automatically, + // leave this now in order to insert the next one. + if (inautoarg) { + cur.leaveInset(cur.inset()); + cur.posForward(); + inautoarg = false; + } FuncRequest const cmd2(LFUN_ARGUMENT_INSERT, la_pair.first); lyx::dispatch(cmd2); + inautoarg = true; } } @@ -2063,18 +2072,34 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) bool const sel = cur.selection(); doInsertInset(cur, this, cmd, true, true); // Insert auto-insert arguments - bool autoargs = false; + bool autoargs, inautoarg = false; Layout::LaTeXArgMap args = cur.inset().getLayout().args(); Layout::LaTeXArgMap::const_iterator lait = args.begin(); Layout::LaTeXArgMap::const_iterator const laend = args.end(); for (; lait != laend; ++lait) { Layout::latexarg arg = (*lait).second; + if (!inautoarg && arg.insertonnewline && cur.pos() > 0) { + FuncRequest cmd2(LFUN_PARAGRAPH_BREAK); + lyx::dispatch(cmd2); + } if (arg.autoinsert) { // The cursor might have been invalidated by the replaceSelection. cur.buffer()->changed(true); + // If we had already inserted an arg automatically, + // leave this now in order to insert the next one. + if (inautoarg) { + cur.leaveInset(cur.inset()); + cur.posForward(); + inautoarg = false; + if (arg.insertonnewline && cur.pos() > 0) { + FuncRequest cmd2(LFUN_PARAGRAPH_BREAK); + lyx::dispatch(cmd2); + } + } FuncRequest cmd2(LFUN_ARGUMENT_INSERT, (*lait).first); lyx::dispatch(cmd2); autoargs = true; + inautoarg = true; } } if (!autoargs) {