From 7922859449e9b165966f670f2781f2f6ed4f7b87 Mon Sep 17 00:00:00 2001 From: Jan Sundermeyer Date: Fri, 9 Feb 2024 19:17:24 +0100 Subject: [PATCH] fix handling math check in math alias envs --- src/syntaxcheck.cpp | 14 ++++++++++++-- src/tests/syntaxcheck_t.cpp | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/syntaxcheck.cpp b/src/syntaxcheck.cpp index 1abb62bd57..9e11b24303 100644 --- a/src/syntaxcheck.cpp +++ b/src/syntaxcheck.cpp @@ -442,8 +442,18 @@ bool SyntaxCheck::checkCommand(const QString &cmd, const StackEnvironment &envs) bool textOrMathEnvUsed=false; for (int i = envs.size()-1; i > -1; --i) { Environment env = envs.at(i); - if(textOrMathEnvUsed &&(env.name=="math" || env.name=="text" )){ - continue; // only the lowest text/math is valid as they can be used alternately + if(textOrMathEnvUsed){ + if(env.name=="math" || env.name=="text" ) continue; // only the lowest text/math is valid as they can be used alternately + // look also for alias envs! + QStringList altEnvs = ltxCommands->environmentAliases.values(env.name); + bool skip=false; + foreach (const QString &altEnv, altEnvs) { + if (altEnv=="math" || altEnv=="text" ){ + skip=true; + break; + } + } + if(skip) continue; // only the lowest text/math is valid as they can be used alternately } if (ltxCommands->possibleCommands.contains(env.name) && ltxCommands->possibleCommands.value(env.name).contains(cmd)) return true; diff --git a/src/tests/syntaxcheck_t.cpp b/src/tests/syntaxcheck_t.cpp index ef0b589e1a..1ab5845e99 100644 --- a/src/tests/syntaxcheck_t.cpp +++ b/src/tests/syntaxcheck_t.cpp @@ -414,7 +414,10 @@ void SyntaxCheckTest::checkAllowedMath_data(){ <<"$\\textit{$ {\\alpha}$}$"<