]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Update buffer when an inset or an INFO inset has bee inserted
[lyx.git] / src / Text3.cpp
index a65de1d7514d31bf4e39702e2071aa97f16a134a..7686687815863e94f2ba9e20f8f60e380d008e18 100644 (file)
@@ -1197,6 +1197,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        if (cur.selection())
                                cutSelection(cur, true, false);
                        cur.insert(inset);
+                       cur.forceBufferUpdate();
                        if (inset->editable() && inset->asInsetText())
                                inset->edit(cur, true);
                        else
@@ -1505,6 +1506,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                bool const outer = cmd.argument() == "outer";
                bool const previous = cmd.argument() == "previous";
                bool const before = cmd.argument() == "before";
+               bool const normal = cmd.argument().empty();
                Paragraph const & para = cur.paragraph();
                docstring layout;
                if (para.layout().isEnvironment())
@@ -1533,11 +1535,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                if (cpar.params().depth() == 0)
                                        break;
                        }
-                       if (outer && pit < cur.lastpit()) {
-                               // save nesting of following paragraph
-                               cpar = pars_[cur.pit() + 1];
-                               nextpar_depth = cpar.params().depth();
-                       }
+               }
+               if ((outer || normal) && cur.pit() < cur.lastpit()) {
+                       // save nesting of following paragraph
+                       Paragraph cpar = pars_[cur.pit() + 1];
+                       nextpar_depth = cpar.params().depth();
                }
                if (before)
                        cur.top().setPitPos(cur.pit(), 0);
@@ -1562,11 +1564,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                else
                        lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
                lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
-               if (outer && nextpar_depth > 0) {
+               if ((outer || normal) && nextpar_depth > 0) {
                        // restore nesting of following paragraph
                        DocIterator scur = cur;
+                       depth_type const max_depth = cur.paragraph().getMaxDepthAfter();
                        cur.forwardPar();
-                       while (cur.paragraph().params().depth() < nextpar_depth)
+                       while (cur.paragraph().params().depth() <= min(nextpar_depth, max_depth))
                                lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT));
                        cur.setCursor(scur);
                }
@@ -1932,6 +1935,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        break;
                cur.recordUndo();
                insertInset(cur, inset);
+               cur.forceBufferUpdate();
                cur.posForward();
                break;
        }
@@ -3243,7 +3247,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        break;
                }
                else if (cur.paragraph().layout().isEnvironment()) {
-                       enable = true;
+                       enable = cmd.argument() == "before"
+                               || cur.pos() > 0 || !isFirstInSequence(cur.pit());
                        break;
                }
                enable = false;