]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Fix assertion when checking if change in selection
[lyx.git] / src / output_latex.cpp
index 03b4b44e552213c07a708ff8912fccfe5b58f125..bdc7cb28efd40c513460f75581b327debaab38e2 100644 (file)
@@ -831,9 +831,18 @@ void TeXOnePar(Buffer const & buf,
                os << '{';
        }
 
-       // In some insets (such as Arguments), we cannot use \selectlanguage
+       // In some insets (such as Arguments), we cannot use \selectlanguage.
+       // Also, if an RTL language is set via environment in polyglossia,
+       // only a nested \\text<lang> command will reset the direction for LTR
+       // languages (see # 10111).
+       bool const in_polyglossia_rtl_env =
+               use_polyglossia
+               && runparams.local_font != 0
+               && outer_language->rightToLeft()
+               && !par_language->rightToLeft();
        bool const localswitch = text.inset().forceLocalFontSwitch()
-                       || (using_begin_end && text.inset().forcePlainLayout());
+                       || (using_begin_end && text.inset().forcePlainLayout())
+                       || in_polyglossia_rtl_env;
        if (localswitch) {
                lang_begin_command = use_polyglossia ?
                            "\\text$$lang$$opts{" : lyxrc.language_command_local;
@@ -1174,7 +1183,8 @@ void TeXOnePar(Buffer const & buf,
                                                && style != nextpar->layout())))
                                    || (atSameLastLangSwitchDepth(state)
                                        && state->lang_switch_depth_.size()
-                                       && cur_lang != par_lang))
+                                       && cur_lang != par_lang)
+                                   || in_polyglossia_rtl_env)
                                {
                                        if (using_begin_end && !localswitch)
                                                os << breakln;