dynamic: fix dynamic variables being blocked by flag keywords

fixes #45
This commit is contained in:
Vaxry 2024-05-15 17:45:22 +01:00
parent 073678282e
commit 969cb076e5
4 changed files with 9 additions and 2 deletions

View file

@ -620,7 +620,7 @@ CParseResult CConfig::parseLine(std::string line, bool dynamic) {
if (!h.options.allowFlags && h.name != LHS)
continue;
if (h.options.allowFlags && !LHS.starts_with(h.name))
if (h.options.allowFlags && (!LHS.starts_with(h.name) || LHS.contains(':') /* avoid cases where a category is called the same as a handler */))
continue;
ret = h.func(LHS.c_str(), RHS.c_str());

View file

@ -88,7 +88,7 @@ class CConfigImpl {
Hyprlang::SConfigOptions configOptions;
void parseComment(const std::string& comment);
void parseComment(const std::string& comment);
struct {
bool noError = false;

View file

@ -75,6 +75,10 @@ specialAnonymous {
value = 3
}
flagsStuff {
value = 2
}
testCategory:testValueHex = 0xFFfFaAbB
$RECURSIVE1 = a

View file

@ -98,6 +98,7 @@ int main(int argc, char** argv, char** envp) {
config.addConfigValue("testCategory:testColor1", (Hyprlang::INT)0);
config.addConfigValue("testCategory:testColor2", (Hyprlang::INT)0);
config.addConfigValue("testCategory:testColor3", (Hyprlang::INT)0);
config.addConfigValue("flagsStuff:value", (Hyprlang::INT)0);
config.addConfigValue("myColors:pink", (Hyprlang::INT)0);
config.addConfigValue("myColors:green", (Hyprlang::INT)0);
config.addConfigValue("myColors:random", (Hyprlang::INT)0);
@ -170,6 +171,8 @@ int main(int argc, char** argv, char** envp) {
EXPECT(std::any_cast<int64_t>(config.getConfigValue("testCategory:testValueHex")), (Hyprlang::INT)0xAABBCCDD);
EXPECT(config.parseDynamic("testStringColon", "1:3:3:7").error, false);
EXPECT(std::any_cast<const char*>(config.getConfigValue("testStringColon")), std::string{"1:3:3:7"});
EXPECT(config.parseDynamic("flagsStuff:value = 69").error, false);
EXPECT(std::any_cast<int64_t>(config.getConfigValue("flagsStuff:value")), (Hyprlang::INT)69);
// test dynamic special
config.addSpecialConfigValue("specialGeneric:one", "boom", (Hyprlang::INT)0);