diff --git a/src/config.cpp b/src/config.cpp index 575968d..f377d57 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -264,13 +264,15 @@ CParseResult CConfig::configSetValueSafe(const std::string& command, const std:: CParseResult result; std::string valueName; + std::string catPrefix; for (auto& c : impl->categories) { valueName += c + ':'; + catPrefix += c + ':'; } valueName += command; - const auto VALUEONLYNAME = valueName.contains(":") ? valueName.substr(valueName.find_last_of(':') + 1) : valueName; + const auto VALUEONLYNAME = command.starts_with(catPrefix) ? command.substr(catPrefix.length()) : command; auto VALUEIT = impl->values.find(valueName); if (VALUEIT == impl->values.end()) { diff --git a/tests/config/config.conf b/tests/config/config.conf index 3dbe429..e0f564f 100644 --- a/tests/config/config.conf +++ b/tests/config/config.conf @@ -15,6 +15,8 @@ source = ./colors.conf customType = abc +testStringColon = ee:ee:ee + testCategory { testValueInt = 123456 testValueHex = 0xF diff --git a/tests/parse/main.cpp b/tests/parse/main.cpp index ccbad97..ef7524f 100644 --- a/tests/parse/main.cpp +++ b/tests/parse/main.cpp @@ -85,6 +85,7 @@ int main(int argc, char** argv, char** envp) { config.addConfigValue("testFloat", 0.F); config.addConfigValue("testVec", Hyprlang::SVector2D{69, 420}); config.addConfigValue("testString", ""); + config.addConfigValue("testStringColon", ""); config.addConfigValue("testEnv", ""); config.addConfigValue("testVar", (Hyprlang::INT)0); config.addConfigValue("testStringQuotes", ""); @@ -145,6 +146,7 @@ int main(int argc, char** argv, char** envp) { EXPECT(std::any_cast(config.getConfigValue("testCategory:testColor1")), (Hyprlang::INT)0xFFFFFFFF); EXPECT(std::any_cast(config.getConfigValue("testCategory:testColor2")), (Hyprlang::INT)0xFF000000); EXPECT(std::any_cast(config.getConfigValue("testCategory:testColor3")), (Hyprlang::INT)0x22ffeeff); + EXPECT(std::any_cast(config.getConfigValue("testStringColon")), std::string{"ee:ee:ee"}); // test static values std::cout << " → Testing static values\n"; @@ -165,6 +167,8 @@ int main(int argc, char** argv, char** envp) { EXPECT(barrelRoll, true); EXPECT(config.parseDynamic("testCategory:testValueHex", "0xaabbccdd").error, false); EXPECT(std::any_cast(config.getConfigValue("testCategory:testValueHex")), (Hyprlang::INT)0xAABBCCDD); + EXPECT(config.parseDynamic("testStringColon", "1:3:3:7").error, false); + EXPECT(std::any_cast(config.getConfigValue("testStringColon")), std::string{"1:3:3:7"}); // test dynamic special config.addSpecialConfigValue("specialGeneric:one", "boom", (Hyprlang::INT)0);