mirror of
https://github.com/hyprwm/hyprlang.git
synced 2025-12-20 03:50:02 +01:00
core: fix negating of ifs
This commit is contained in:
parent
235ce61cba
commit
13865735fe
2 changed files with 11 additions and 7 deletions
|
|
@ -535,11 +535,6 @@ std::optional<std::string> CConfigImpl::parseComment(const std::string& comment)
|
|||
break;
|
||||
}
|
||||
|
||||
if (args[i] == "!") {
|
||||
negated = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args[i] == "endif") {
|
||||
if (!currentFlags.inAnIfBlock)
|
||||
return "stray endif";
|
||||
|
|
@ -557,12 +552,17 @@ std::optional<std::string> CConfigImpl::parseComment(const std::string& comment)
|
|||
if (currentFlags.inAnIfBlock)
|
||||
return "nested if statements are not allowed";
|
||||
|
||||
if (ifBlockVariable.starts_with("!")) {
|
||||
negated = true;
|
||||
ifBlockVariable = ifBlockVariable.substr(1);
|
||||
}
|
||||
|
||||
currentFlags.inAnIfBlock = true;
|
||||
|
||||
if (const auto VAR = getVariable(ifBlockVariable); VAR)
|
||||
currentFlags.ifBlockFailed = !VAR->truthy();
|
||||
currentFlags.ifBlockFailed = negated ? VAR->truthy() : !VAR->truthy();
|
||||
else
|
||||
currentFlags.ifBlockFailed = true;
|
||||
currentFlags.ifBlockFailed = !negated;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,12 @@ source = ./colors.conf
|
|||
|
||||
customType = abc
|
||||
|
||||
# hyprlang if ! NONEXISTENT_VAR
|
||||
|
||||
testStringColon = ee:ee:ee
|
||||
|
||||
# hyprlang endif
|
||||
|
||||
# hyprlang noerror true
|
||||
|
||||
errorVariable = true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue