]> git.lyx.org Git - features.git/commitdiff
Reset InsetArgument language after passthru status change
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 15 Sep 2017 14:21:05 +0000 (16:21 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 15 Sep 2017 14:23:50 +0000 (16:23 +0200)
Fixes: #10664
(cherry picked from commit d8c018b8c691f6bc3ebbb5f78bffc0b3f87c228f)

src/insets/InsetArgument.cpp
src/insets/InsetArgument.h

index e22bcdeb4e59385078a0547293c5d788096b4d31..5e51f42044232a50c9da4961c94866ab67991f41 100644 (file)
@@ -68,6 +68,8 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
                it.inset().getLayout().args() : it.paragraph().layout().args();
        pass_thru_context_ = insetlayout ?
                it.inset().getLayout().isPassThru() : it.paragraph().layout().pass_thru;
+       // Record PassThru status in order to act on changes.
+       bool const former_pass_thru = pass_thru_;
 
        // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
        if (name_ == "999") {
@@ -139,6 +141,16 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
                labelstring_ = _("Unknown Argument");
                tooltip_ = _("Argument not known in this Layout. Will be supressed in the output.");
        }
+
+       if (former_pass_thru != pass_thru_) {
+               // PassThru status changed. We might need to update
+               // the language of the contents
+               Language const * l  = insetlayout
+                       ? it.inset().buffer().language()
+                       : it.buffer()->language();
+               fixParagraphLanguage(l);
+       }
+
        setButtonLabel();
        InsetCollapsable::updateBuffer(it, utype);
 }
@@ -187,8 +199,13 @@ void InsetArgument::doDispatch(Cursor & cur, FuncRequest & cmd)
                // forcing to latex_language in InsetText::dispatch(),
                // since this does not play nicely with inherited pass_thru
                // (see #8471).
-               if (pass_thru_ && !pass_thru_local_)
+               if (pass_thru_ && !pass_thru_local_) {
                        text().dispatch(cur, cmd);
+                       // For the paste operations, check if we have
+                       // non-latex_language, and if so, fix.
+                       if (cmd.action() != LFUN_SELF_INSERT)
+                               fixParagraphLanguage(buffer().params().language);
+               }
                else
                        InsetCollapsable::doDispatch(cur, cmd);
                break;
@@ -322,4 +339,13 @@ void InsetArgument::addToToc(DocIterator const & dit, bool output_active,
 }
 
 
+void InsetArgument::fixParagraphLanguage(Language const * l)
+{
+       Font font(inherit_font, l);
+       if (pass_thru_)
+               font.setLanguage(latex_language);
+       paragraphs().front().resetFonts(font);
+}
+
+
 } // namespace lyx
index cbd03375e00d8ddade603ea155586174be4a2308..86de5b1ca115ca5173fcc5e331920d1bfe4792b2 100644 (file)
@@ -92,6 +92,8 @@ private:
        ///
        docstring toolTip(BufferView const & bv, int, int) const;
        ///
+       void fixParagraphLanguage(Language const *);
+       ///
        std::string name_;
        ///
        docstring labelstring_;