What do you think of the attached patch? It adds braces to restrict the scope of the variable 'potential_terms'. I like this style, since it makes it easier for me to read, but I wonder if others would find it annoying. For example, it adds an extra layer of indentation.
Scott
From b442cc74cc628533b68f72fc0c0ad5fadcaa9e9b Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> Date: Fri, 18 Nov 2022 12:35:07 -0500 Subject: [PATCH] Restrict scope of a variable The scope of 'potential_terms' is now restricted, as was the case before d9847302. --- src/insets/InsetIndex.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 54757a7a97..2b4f9bc72b 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -373,15 +373,17 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const // Handle primary, secondary, and tertiary terms (entries, subentries, and subsubentries, for LaTeX). vector<docstring> terms; - const vector<docstring> potential_terms = getSubentriesAsText(runparams); - if (!potential_terms.empty()) { - terms = potential_terms; - // The main term is not present in the vector, as it's not a subentry. The main index term is inserted raw in - // the index inset. Considering that the user either uses the new or the legacy mechanism, the main term is the - // full string within this inset (i.e. without the subinsets). - terms.insert(terms.begin(), latexString); - } else { - terms = getVectorFromString(indexTerms, from_ascii("!"), false); + { + const vector<docstring> potential_terms = getSubentriesAsText(runparams); + if (!potential_terms.empty()) { + terms = potential_terms; + // The main term is not present in the vector, as it's not a subentry. The main index term is inserted raw in + // the index inset. Considering that the user either uses the new or the legacy mechanism, the main term is the + // full string within this inset (i.e. without the subinsets). + terms.insert(terms.begin(), latexString); + } else { + terms = getVectorFromString(indexTerms, from_ascii("!"), false); + } } // Handle ranges. Happily, in the raw LaTeX mode, (| and |) can only be at the end of the string! -- 2.34.1
signature.asc
Description: PGP signature
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel