]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
typo
[lyx.git] / src / output_latex.cpp
index 4124d2dd1c92fde9f5cf08cb62ca29808ed1277f..db56ff608bb4391863fe33e04e262201120951ce 100644 (file)
@@ -781,6 +781,10 @@ void TeXOnePar(Buffer const & buf,
                ? nullptr : &paragraphs.at(pit + 1);
 
        bool const intitle_command = style.intitle && style.isCommand();
+       // Intitle commands switch languages locally, thus increase
+       // language nesting level
+       if (intitle_command)
+               state->nest_level_ += 1;
 
        if (style.pass_thru) {
                Font const outerfont = text.outerFont(pit);
@@ -913,10 +917,12 @@ void TeXOnePar(Buffer const & buf,
                && runparams.local_font != nullptr
                && outer_language->rightToLeft()
                && !par_language->rightToLeft();
-       bool const localswitch = runparams_in.for_search
+       bool const localswitch =
+                       (runparams_in.for_search
                        || text.inset().forceLocalFontSwitch()
                        || (using_begin_end && text.inset().forcePlainLayout())
-                       || in_polyglossia_rtl_env;
+                       || in_polyglossia_rtl_env)
+                       && !text.inset().forceParDirectionSwitch();
        if (localswitch) {
                lang_begin_command = use_polyglossia ?
                            "\\text$$lang$$opts{" : lyxrc.language_command_local;
@@ -1452,6 +1458,10 @@ void TeXOnePar(Buffer const & buf,
                }
        }
 
+       // Reset language nesting level after intitle command
+       if (intitle_command)
+               state->nest_level_ -= 1;
+
        LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " done; ptr "
                << &par << " next " << nextpar);
 
@@ -1643,7 +1653,9 @@ void latexParagraphs(Buffer const & buf,
                                        "$$lang",
                                        mainlang))
                        << '\n';
-               if (using_begin_end)
+               // If we have language_auto_begin, the stack will
+               // already be empty, nothing to pop()
+               if (using_begin_end && !lyxrc.language_auto_begin)
                        popLanguageName();
        }