feat(config): merge included arrays - #175
Conversation
| for (auto&& elem : *overlayArray) { | ||
| elem.visit([&](auto&& val) { | ||
| using T = std::decay_t<decltype(val)>; | ||
| baseArray->push_back(T(std::move(val))); |
There was a problem hiding this comment.
I assumed the same applies to array values as to other values, as noted by the comment further below ("Move via visit to preserve toml++ source regions (copies reset them).")
| continue; | ||
| } | ||
| } | ||
| } else if (auto* overlayArray = value.as_array()) { |
There was a problem hiding this comment.
This currently turns all arrays into append-only arrays. You can't reset them to an empty list, or override them entirely. This is a question of user experience that I can't answer, so this is a draft until I have feedback on this.
We could narrow this down to only merge arrays of tables, through value.is_array_of_tables().
That would still serve the use case of window and layer rules spread over multiple configs, but makes it easy to override primitive arrays.
I will add tests once it's clear what behavior is desired / acceptable.
|
Agreed with your second comment: let's narrow it to arrays of tables only. Appending every array breaks the fixed-size ones (position, calibration_matrix) by making them too long, and would make general.autostart run the included commands twice. |
Summary
When merging values of all included configs, array values are now concatenated.
This is particularly useful for window rules.
Motivation
Re-defining arrays over separate included config files only leaves the array values of the last applied config.
Type of Change
Related Issue
Testing
Manual Coverage
Screenshots / Videos
Checklist
SCOPE.md, or its scope was agreed in an issue or on Discord first.CONTRIBUTING.md.just format, or this PR has no C++ changes.docs/andexamples/config.toml, or this PR does not change user-facing configuration or behavior.Additional Notes