The code was not accounting for partial preview of the source code
and was trying to pop a language that was never pushed.
This commit is contained in:
Enrico Forestieri 2017-05-16 20:20:32 +02:00
parent d75c0ec8b1
commit bfe0d52e97

View File

@ -212,7 +212,8 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
// For polyglossia, switch language outside of environment, if possible. // For polyglossia, switch language outside of environment, if possible.
if (par_lang != prev_par_lang) { if (par_lang != prev_par_lang) {
if (!lang_end_command.empty() && if (langOpenedAtThisLevel(state) &&
!lang_end_command.empty() &&
prev_par_lang != doc_lang && prev_par_lang != doc_lang &&
atSameLastLangSwitchDepth(state) && atSameLastLangSwitchDepth(state) &&
!prev_par_lang.empty()) { !prev_par_lang.empty()) {
@ -812,7 +813,8 @@ void TeXOnePar(Buffer const & buf,
&& priorpar->getDepth() <= par.getDepth()) && priorpar->getDepth() <= par.getDepth())
|| priorpar->getDepth() < par.getDepth()))) || priorpar->getDepth() < par.getDepth())))
{ {
if (!lang_end_command.empty() && if (langOpenedAtThisLevel(state) &&
!lang_end_command.empty() &&
prev_lang != outer_lang && prev_lang != outer_lang &&
!prev_lang.empty() && !prev_lang.empty() &&
(!use_polyglossia || !style.isEnvironment())) (!use_polyglossia || !style.isEnvironment()))
@ -1109,8 +1111,10 @@ void TeXOnePar(Buffer const & buf,
if (use_polyglossia) if (use_polyglossia)
pushPolyglossiaLang(current_lang, localswitch); pushPolyglossiaLang(current_lang, localswitch);
} }
} else if (!par_lang.empty()) { } else if (langOpenedAtThisLevel(state) &&
// If we are in an environment, we have to close the "outer" language afterwards !par_lang.empty()) {
// If we are in an environment, we have to
// close the "outer" language afterwards
string const & pol_lang = openPolyglossiaLang(state); string const & pol_lang = openPolyglossiaLang(state);
if (!style.isEnvironment() if (!style.isEnvironment()
|| (close_lang_switch || (close_lang_switch