[LyX/master] Fix language setting after verbatim par if a secondary language was in effect (#13361)

Juergen Spitzmueller spitz at lyx.org
Tue Sep 8 09:54:27 UTC 2026


commit ad1e9f18b5db7253a1d0ed8956fc02d58e455831
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Sep 8 11:53:40 2026 +0200

    Fix language setting after verbatim par if a secondary language was in effect (#13361)
---
 src/output_latex.cpp | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 4a7d6334ca..8a15aa0515 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -955,9 +955,9 @@ void TeXOnePar(Buffer const & buf,
 	// environment with nesting depth greater than (or equal to, but with
 	// a different layout) the current one. If there is no previous
 	// paragraph, the previous language is the outer language.
-	// Note further that we take the outer language also if the prior par
-	// is PassThru, since in that case it has latex_language, and all secondary
-	// languages have been closed (#10793).
+	// Note further that if the prior par is PassThru, we check the language of
+	// the first non-PassThru paragraph before since PassThru pars have latex_language
+	// (#10793).
 	bool const use_prev_env_language = state->prev_env_language_ != nullptr
 			&& priorpar
 			&& priorpar->layout().isEnvironment()
@@ -968,27 +968,27 @@ void TeXOnePar(Buffer const & buf,
 	// We need to ignore previous intitle commands since languages
 	// are switched locally there (# 11514)
 	// There might be paragraphs before the title, so we check this.
-	Paragraph * prior_nontitle_par = nullptr;
+	// Since we are interested in language, we also skip passThru pars (#13361).
+	Paragraph * prior_nontitle_nonpt_par = nullptr;
 	if (!intitle_command) {
 		pit_type ppit = pit;
 		while (ppit > 0) {
 			--ppit;
 			Paragraph const * tmppar = &paragraphs.at(ppit);
-			if (tmppar->layout().intitle && tmppar->layout().isCommand())
+			if ((tmppar->layout().intitle && tmppar->layout().isCommand())
+			     || tmppar->isPassThru())
 				continue;
-			prior_nontitle_par = const_cast<Paragraph*>(tmppar);
+			prior_nontitle_nonpt_par = const_cast<Paragraph*>(tmppar);
 			break;
 		}
 	}
-	bool const have_prior_nptpar =
-			prior_nontitle_par && !prior_nontitle_par->isPassThru();
 	Language const * const prev_language =
 		runparams_in.find_effective()
 			? languages.getLanguage("ignore")
-			: (have_prior_nptpar)
+			: (prior_nontitle_nonpt_par)
 				? (use_prev_env_language 
 					? state->prev_env_language_
-					: prior_nontitle_par->getParLanguage(bparams))
+					: prior_nontitle_nonpt_par->getParLanguage(bparams))
 				: outer_language;
 
 	bool const use_polyglossia = runparams.use_polyglossia;
@@ -1043,7 +1043,7 @@ void TeXOnePar(Buffer const & buf,
 		&& runparams.local_font != nullptr
 		&& outer_language->rightToLeft()
 		&& !par_language->rightToLeft()
-		&& !(have_prior_nptpar
+		&& !(prior_nontitle_nonpt_par
 		     && (prev_language->rightToLeft() != par_language->rightToLeft()));
 	bool const localswitch =
 			(runparams_in.find_effective()


More information about the lyx-cvs mailing list