summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2024-01-14 17:25:15 +0100
committerGitHub <noreply@github.com>2024-01-14 20:25:15 +0400
commit94ede16ee4af8869fd6415b3530c7e12c8681578 (patch)
treed1a298b6c1333ca37c88b8318ba06405004a0b08
parentb82a49ce0cc99ef40a1ef49b6f3b39ef598f42d1 (diff)
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 01514dde..12df09f9 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(())
}
}