+ pit_type pit = cur.pit();
+ Paragraph const & par = pars_[pit];
+ bool lastpar = (pit == pit_type(pars_.size() - 1));
+ Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
+ pit_type prev = pit;
+ if (pit > 0) {
+ if (!pars_[pit - 1].layout().isEnvironment())
+ prev = depthHook(pit, par.getDepth());
+ else if (pars_[pit - 1].getDepth() >= par.getDepth())
+ prev = pit - 1;
+ }
+ if (prev < pit && cur.pos() == par.beginOfBody()
+ && !par.size() && !par.isEnvSeparator(cur.pos())
+ && !par.layout().isCommand()
+ && pars_[prev].layout() != par.layout()
+ && pars_[prev].layout().isEnvironment()
+ && !nextpar.isEnvSeparator(nextpar.beginOfBody())) {
+ if (par.layout().isEnvironment()
+ && pars_[prev].getDepth() == par.getDepth()) {
+ docstring const layout = par.layout().name();
+ DocumentClass const & tc = bv->buffer().params().documentClass();
+ lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name()));
+ lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
+ lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
+ lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
+ } else {
+ lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "plain"));
+ breakParagraph(cur);
+ }
+ Font const f(inherit_font, cur.current_font.language());
+ pars_[cur.pit() - 1].resetFonts(f);
+ } else {
+ if (par.isEnvSeparator(cur.pos()))
+ cur.posForward();
+ breakParagraph(cur, cmd.argument() == "inverse");
+ }