]> git.lyx.org Git - features.git/blobdiff - src/Text3.cpp
Code cleanup in GuiCompleter
[features.git] / src / Text3.cpp
index b1bf879a55a02755b840d76cd03eb3e1c898fc97..529e756a97742b0035b180af1dc01c8eba84f091 100644 (file)
@@ -252,7 +252,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
        cur.recordUndo();
        if (cmd.action() == LFUN_ARGUMENT_INSERT) {
                bool cotextinsert = false;
-               InsetArgument const * const ia = static_cast<InsetArgument const *>(inset);
+               InsetArgument * const ia = static_cast<InsetArgument *>(inset);
                Layout const & lay = cur.paragraph().layout();
                Layout::LaTeXArgMap args = lay.args();
                Layout::LaTeXArgMap::const_iterator const lait = args.find(ia->name());
@@ -275,6 +275,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
                        else
                                ds = cur.paragraph().asString();
                        text->insertInset(cur, inset);
+                       ia->init(cur.paragraph());
                        if (edit)
                                inset->edit(cur, true);
                        // Now put co-text into inset
@@ -298,8 +299,11 @@ static bool doInsertInset(Cursor & cur, Text * text,
                         * paragraph and the inset allows setting layout
                         * FIXME: this does not work as expected when change tracking is on
                         *   However, we do not really know what to do in this case.
+                        * FIXME: figure out a good test in the environment case (see #12251).
                         */
-                       if (cur.paragraph().empty() && !inset->forcePlainLayout()) {
+                       if (cur.paragraph().layout().isCommand()
+                            && cur.paragraph().empty()
+                            && !inset->forcePlainLayout()) {
                                cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
                                move_layout = true;
                        }
@@ -321,6 +325,11 @@ static bool doInsertInset(Cursor & cur, Text * text,
                inset_text->setOuterFont(cur.bv(), font.fontInfo());
        }
 
+       if (cmd.action() == LFUN_ARGUMENT_INSERT) {
+               InsetArgument * const ia = static_cast<InsetArgument *>(inset);
+               ia->init(cur.paragraph());
+       }
+
        if (edit)
                inset->edit(cur, true);
 
@@ -1515,7 +1524,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                pasteFromStack(cur, bv->buffer().errorList("Paste"), 0);
                        else if (theClipboard().hasTextContents()) {
                                if (pasteClipboardText(cur, bv->buffer().errorList("Paste"),
-                                                      true, Clipboard::AnyTextType))
+                                                      !cur.paragraph().parbreakIsNewline(),
+                                                          Clipboard::AnyTextType))
                                        tryGraphics = false;
                        }
                        if (tryGraphics && theClipboard().hasGraphicsContents())
@@ -2756,11 +2766,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        bv->buffer().params().spellignore().push_back(wl);
                        cur.recordUndo();
                        // trigger re-check of whole buffer
-                       ParagraphList & pars = bv->buffer().paragraphs();
-                       ParagraphList::iterator pit = pars.begin();
-                       ParagraphList::iterator pend = pars.end();
-                       for (; pit != pend; ++pit)
-                               pit->requestSpellCheck();
+                       bv->buffer().requestSpellcheck();
                }
                break;
        }
@@ -2794,11 +2800,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        bv->buffer().params().spellignore().erase(it);
                        cur.recordUndo();
                        // trigger re-check of whole buffer
-                       ParagraphList & pars = bv->buffer().paragraphs();
-                       ParagraphList::iterator pit = pars.begin();
-                       ParagraphList::iterator pend = pars.end();
-                       for (; pit != pend; ++pit)
-                               pit->requestSpellCheck();
+                       bv->buffer().requestSpellcheck();
                }
                break;
        }
@@ -3431,6 +3433,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                break;
 
        case LFUN_PRIMARY_SELECTION_PASTE:
+               status.setUnknown(!theSelection().supported());
                enable = cur.selection() || !theSelection().empty();
                break;