From 94ede16ee4af8869fd6415b3530c7e12c8681578 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 14 Jan 2024 17:25:15 +0100 Subject: 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. --- CHANGELOG.md | 1 + alacritty_config/src/lib.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 { impl<'de, T: Deserialize<'de>> SerdeReplace for HashMap { fn replace(&mut self, value: Value) -> Result<(), Box> { - replace_simple(self, value) + // Deserialize replacement as HashMap. + let hashmap: HashMap = Self::deserialize(value)?; + + // Merge the two HashMaps, replacing existing values. + for (key, value) in hashmap { + self.insert(key, value); + } + + Ok(()) } } -- cgit v1.2.3