diff options
Diffstat (limited to 'crates/shirabe/src/command/config_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/config_command.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 7bd65b6..308d557 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -823,14 +823,27 @@ impl Command for ConfigCommand { PhpMixed::List(value.as_list().cloned().unwrap_or_default()), ); } else { - // PHP "+" operator on arrays: keep keys from left, fill from right - let mut merged: IndexMap<String, PhpMixed> = - value.as_array().cloned().unwrap_or_default(); - if let Some(cv) = current_value.as_array() { - for (k, v) in cv { - if !merged.contains_key(k) { - merged.insert(k.clone(), v.clone()); - } + // PHP "+" operator on arrays: keep keys from left, fill from right. + // A list participates with its integer indices as keys. + let mut merged: IndexMap<String, PhpMixed> = match &value { + PhpMixed::List(l) => l + .iter() + .enumerate() + .map(|(i, v)| (i.to_string(), v.clone())) + .collect(), + _ => value.as_array().cloned().unwrap_or_default(), + }; + let fill: IndexMap<String, PhpMixed> = match ¤t_value { + PhpMixed::List(l) => l + .iter() + .enumerate() + .map(|(i, v)| (i.to_string(), v.clone())) + .collect(), + _ => current_value.as_array().cloned().unwrap_or_default(), + }; + for (k, v) in fill { + if !merged.contains_key(&k) { + merged.insert(k, v); } } value = PhpMixed::Array(merged); |
