mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 12:05:58 +01:00
config: variables update their value when set again (#4263)
* variables update their value when set again * only sort if new variable is found * clang-format
This commit is contained in:
parent
3c33d4b9dd
commit
4f26c4e1eb
1 changed files with 13 additions and 3 deletions
|
@ -395,10 +395,20 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
|||
if (!COMMAND.starts_with("device:") /* devices parsed later */ && !COMMAND.starts_with("plugin:") /* plugins parsed later */) {
|
||||
if (COMMAND[0] == '$') {
|
||||
// register a dynamic var
|
||||
bool found = false;
|
||||
for (auto& [var, val] : configDynamicVars) {
|
||||
if (var == COMMAND.substr(1)) {
|
||||
Debug::log(LOG, "Registered new value for dynamic var \"{}\" -> {}", COMMAND, VALUE);
|
||||
val = VALUE;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
Debug::log(LOG, "Registered dynamic var \"{}\" -> {}", COMMAND, VALUE);
|
||||
configDynamicVars.emplace_back(std::make_pair<>(COMMAND.substr(1), VALUE));
|
||||
|
||||
std::sort(configDynamicVars.begin(), configDynamicVars.end(), [&](const auto& a, const auto& b) { return a.first.length() > b.first.length(); });
|
||||
}
|
||||
} else {
|
||||
parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field.";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue