From: Jean-Marc Lasgouttes Date: Sun, 26 Mar 2023 18:28:00 +0000 (+0200) Subject: When breaking a paragraph, do not reset depth X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=13d24c711e745ea0c6ea2019236025d14bd2defa;p=features.git When breaking a paragraph, do not reset depth Remove some logic that would reset depth when editing non-environment stuff (e.g. Standard layout) at non-zero depth. The current way of decreasing depth is to use paragraph-break in an empty paragraph. See discussion in ticket #2445 for why this code happened. Fixes bug #12750. --- diff --git a/src/Text.cpp b/src/Text.cpp index a61e32574a..dfef748640 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -716,9 +716,8 @@ double Text::spacing(Paragraph const & par) const /** * This breaks a paragraph at the specified position. * The new paragraph will: - * - Decrease depth by one (or change layout to default layout) when - * keep_layout == false - * - keep current depth and layout when keep_layout == true + * - change layout to default layout when keep_layout == false + * - keep layout when keep_layout == true */ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos, bool keep_layout) @@ -733,21 +732,13 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos, // remember to set the inset_owner tmp->setInsetOwner(&par.inInset()); - // without doing that we get a crash when typing at the - // end of a paragraph - tmp->setPlainOrDefaultLayout(bparams.documentClass()); + tmp->params().depth(par.params().depth()); if (keep_layout) { tmp->setLayout(par.layout()); tmp->setLabelWidthString(par.params().labelWidthString()); - tmp->params().depth(par.params().depth()); - } else if (par.params().depth() > 0) { - Paragraph const & hook = pars[text.outerHook(par_offset)]; - tmp->setLayout(hook.layout()); - // not sure the line below is useful - tmp->setLabelWidthString(par.params().labelWidthString()); - tmp->params().depth(hook.params().depth()); - } + } else + tmp->setPlainOrDefaultLayout(bparams.documentClass()); bool const isempty = (par.allowEmpty() && par.empty());