commit 43a6fe8375882bd0719994b3cb31e0895209a361
Author: Enrico Forestieri <for...@lyx.org>
Date:   Thu Nov 2 10:35:58 2017 +0100

    Fix #10778 (issue with CJK and language nesting)
    
    When using CJK, don't try to close a language that was never
    opened before, such as when it is the main language.
    
    (cherry picked from commit 7e51b5f30196fa0679a7c3c32dc75bca91520f32)
---
 src/Paragraph.cpp    |    1 +
 src/output_latex.cpp |    8 ++++++++
 src/output_latex.h   |    7 +++++++
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 8598969..6f51486 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2542,6 +2542,7 @@ void Paragraph::latex(BufferParams const & bparams,
                bool const using_begin_end = runparams.use_polyglossia ||
                                                !lang_end_command.empty();
                if (!running_lang.empty() &&
+                   (!using_begin_end || running_lang == openLanguageName()) &&
                    current_font.language()->encoding()->package() == 
Encoding::CJK) {
                                string end_tag = subst(lang_end_command,
                                                        "$$lang",
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 02667aa..1431bbb 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -532,6 +532,14 @@ void popLanguageName()
 }
 
 
+string const & openLanguageName()
+{
+       OutputState * state = getOutputState();
+
+       return openLanguageName(state);
+}
+
+
 namespace {
 
 void addArgInsets(Paragraph const & par, string const & prefix,
diff --git a/src/output_latex.h b/src/output_latex.h
index 0969d22..1dd9689 100644
--- a/src/output_latex.h
+++ b/src/output_latex.h
@@ -39,6 +39,13 @@ void pushLanguageName(std::string const & lang, bool 
localswitch = false);
  */
 void popLanguageName();
 
+/** Return a reference to the last active language opened with
+    polyglossia or when using begin/end commands. If none or when
+    using babel with only a begin command, return a reference to
+    an empty string.
+ */
+std::string const & openLanguageName();
+
 /** Export optional and required arguments of the paragraph \p par.
     Non-existing required arguments are output empty: {}.
  */

Reply via email to