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.
This commit is contained in:
Christian Duerr 2024-01-14 17:25:15 +01:00 committed by GitHub
parent b82a49ce0c
commit 94ede16ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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(())
}
}