mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Fix merging child stack into parent (#12426)
# Description Fixes #12423 where changes to mutable variables are not properly persisted after a REPL entry.
This commit is contained in:
@ -337,12 +337,6 @@ impl PluginTest {
|
||||
// All equal, and same length
|
||||
Ok(true)
|
||||
}
|
||||
(Value::Range { val: a_rng, .. }, Value::Range { val: b_rng, .. }) => {
|
||||
Ok(a_rng.inclusion == b_rng.inclusion
|
||||
&& self.value_eq(&a_rng.from, &b_rng.from)?
|
||||
&& self.value_eq(&a_rng.to, &b_rng.to)?
|
||||
&& self.value_eq(&a_rng.incr, &b_rng.incr)?)
|
||||
}
|
||||
// Must collect lazy records to compare.
|
||||
(Value::LazyRecord { val: a_val, .. }, _) => self.value_eq(&a_val.collect()?, b),
|
||||
(_, Value::LazyRecord { val: b_val, .. }) => self.value_eq(a, &b_val.collect()?),
|
||||
|
@ -112,7 +112,7 @@ impl Stack {
|
||||
///
|
||||
/// Here it is assumed that child was created with a call to Stack::with_parent
|
||||
/// with parent
|
||||
pub fn with_changes_from_child(parent: Arc<Stack>, mut child: Stack) -> Stack {
|
||||
pub fn with_changes_from_child(parent: Arc<Stack>, child: Stack) -> Stack {
|
||||
// we're going to drop the link to the parent stack on our new stack
|
||||
// so that we can unwrap the Arc as a unique reference
|
||||
//
|
||||
@ -121,15 +121,18 @@ impl Stack {
|
||||
drop(child.parent_stack);
|
||||
let mut unique_stack = Stack::unwrap_unique(parent);
|
||||
|
||||
unique_stack.vars.append(&mut child.vars);
|
||||
unique_stack
|
||||
.vars
|
||||
.retain(|(var, _)| !child.parent_deletions.contains(var));
|
||||
for (var, value) in child.vars {
|
||||
unique_stack.add_var(var, value);
|
||||
}
|
||||
unique_stack.env_vars = child.env_vars;
|
||||
unique_stack.env_hidden = child.env_hidden;
|
||||
unique_stack.active_overlays = child.active_overlays;
|
||||
unique_stack
|
||||
.vars
|
||||
.retain(|(var, _)| !child.parent_deletions.contains(var));
|
||||
unique_stack
|
||||
}
|
||||
|
||||
pub fn with_env(
|
||||
&mut self,
|
||||
env_vars: &[EnvVars],
|
||||
|
Reference in New Issue
Block a user