Skip to content

Commit

Permalink
into_config() muts a copy of the previous config
Browse files Browse the repository at this point in the history
  • Loading branch information
webbedspace committed Dec 2, 2022
1 parent 212673f commit abce5a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions crates/nu-protocol/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ pub struct ExploreConfig {
}

impl Value {
pub fn into_config(self) -> Result<Config, ShellError> {
pub fn into_config(self, config: &Config) -> Result<Config, ShellError> {
let v = self.as_record();

let mut config = Config::default();

// TBW
let mut config = config.clone();
let mut legacy_options_used = false;

if let Ok(v) = v {
Expand Down
2 changes: 1 addition & 1 deletion crates/nu-protocol/src/engine/engine_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl EngineState {
// NOTE: currently (Dec 2022) the subrecords of config.menus, config.keybindings and config.hooks
// are NOT reconstructed by config_to_nu_record(), but restored from self.config as-is.
// As such, invalid values may persist on them (as into_config() doesn't remove them.
if let Ok(config) = v.clone().into_config() {
if let Ok(config) = v.clone().into_config(&self.config) {
// Don't replace self.config unless into_config() succeeds.
// Note that into_config() produces Err in only very dire circumstances.
self.config = config;
Expand Down

0 comments on commit abce5a4

Please sign in to comment.