From: Juergen Spitzmueller Date: Thu, 18 Jul 2019 15:05:44 +0000 (+0200) Subject: Really fix bug #11616 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e603e991a58f5bb8ecd5dd109fee8348604a689a;p=features.git Really fix bug #11616 With !using_begin_end, we need to compare against the paragraph language since cur_language is always empty. --- diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 7a8bf24c66..891e74cf17 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -1466,7 +1466,8 @@ void latexParagraphs(Buffer const & buf, && runparams.use_CJK)) ) { docstring const cjkenc = bparams.encoding().iconvName() == "UTF-8" - ? from_ascii("UTF8") : from_ascii(bparams.encoding().latexName()); + ? from_ascii("UTF8") + : from_ascii(bparams.encoding().latexName()); os << "\\begin{CJK}{" << cjkenc << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n"; state->open_encoding_ = CJK; @@ -1604,8 +1605,10 @@ void latexParagraphs(Buffer const & buf, // if "auto end" is switched off, explicitly close the language at the end // but only if the last par is in a babel or polyglossia language + Language const * const lastpar_language = + paragraphs.at(lastpit).getParLanguage(bparams); if (maintext && !lyxrc.language_auto_end && !mainlang.empty() && - paragraphs.at(lastpit).getParLanguage(bparams)->encoding()->package() != Encoding::CJK) { + lastpar_language->encoding()->package() != Encoding::CJK) { os << from_utf8(subst(lang_end_command, "$$lang", mainlang)) @@ -1621,12 +1624,14 @@ void latexParagraphs(Buffer const & buf, state->open_encoding_ = none; } // Likewise for polyglossia or when using begin/end commands - // or after an active branch inset with a language switch + // or at the very end of an active branch inset with a language switch Language const * const outer_language = (runparams.local_font != nullptr) ? runparams.local_font->language() : bparams.language; string const & prev_lang = runparams.use_polyglossia ? getPolyglossiaEnvName(outer_language) : outer_language->babel(); + string const lastpar_lang = runparams.use_polyglossia ? + getPolyglossiaEnvName(lastpar_language): lastpar_language->babel(); string const & cur_lang = openLanguageName(state); if (((runparams.inbranch && langOpenedAtThisLevel(state) && prev_lang != cur_lang) || (maintext && !is_child)) && !cur_lang.empty()) { @@ -1636,7 +1641,11 @@ void latexParagraphs(Buffer const & buf, << '\n'; if (using_begin_end) popLanguageName(); - } else if (runparams.inbranch && !using_begin_end && prev_lang != cur_lang) { + } else if (runparams.inbranch && !using_begin_end + && prev_lang != lastpar_lang && !lastpar_lang.empty()) { + // with !using_begin_end, cur_lang is empty, so we need to + // compare against the paragraph language (and we are in the + // last paragraph at this point) os << subst(lang_begin_command, "$$lang", prev_lang) << '\n'; }