aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2024-01-14 17:25:15 +0100
committerChristian Duerr <contact@christianduerr.com>2024-03-19 02:20:53 +0100
commit172a2882cde38a751b0c9931aa49425c4e432076 (patch)
tree2520153617c6645864b6594eacfa557db1086f39
parent9458550c777c54f30ef70954cbcbf774989cc39c (diff)
downloadalacritty-172a2882cde38a751b0c9931aa49425c4e432076.tar.gz
alacritty-172a2882cde38a751b0c9931aa49425c4e432076.zip
Fix env variable overrides through CLI
This fixes an issue where all CLI environment variables would replace existing configuration file variables instead of merging the two maps together. Fixes #7618.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_config/src/lib.rs10
2 files changed, 10 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e34d9e0f..a729bf25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
+- CLI env variables clearing configuration file variables
- Vi inline search/semantic selection expanding across newlines
## 0.13.1
diff --git a/alacritty_config/src/lib.rs b/alacritty_config/src/lib.rs
index 81e43bb8..8da91e19 100644
--- a/alacritty_config/src/lib.rs
+++ b/alacritty_config/src/lib.rs
@@ -61,7 +61,15 @@ impl<'de, T: SerdeReplace + Deserialize<'de>> SerdeReplace for Option<T> {
impl<'de, T: Deserialize<'de>> SerdeReplace for HashMap<String, T> {
fn replace(&mut self, value: Value) -> Result<(), Box<dyn Error>> {
- replace_simple(self, value)
+ // Deserialize replacement as HashMap.
+ let hashmap: HashMap<String, T> = Self::deserialize(value)?;
+
+ // Merge the two HashMaps, replacing existing values.
+ for (key, value) in hashmap {
+ self.insert(key, value);
+ }
+
+ Ok(())
}
}