Fix config creation during printing (#9353)

This commit is contained in:
Jakub Žádník
2023-06-04 22:04:28 +03:00
committed by GitHub
parent df15fc24fe
commit 82e6873702
15 changed files with 66 additions and 100 deletions

View File

@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use nu_protocol::ast::{Call, Expr, PathMember};
use nu_protocol::engine::{EngineState, Stack};
use nu_protocol::{PipelineData, ShellError, Span, Value, VarId};
use nu_protocol::{Config, PipelineData, ShellError, Span, Value, VarId};
use nu_path::canonicalize_with;
@ -303,6 +303,18 @@ pub fn find_in_dirs_env(
Ok(check_dir(lib_dirs).or_else(|| check_dir(lib_dirs_fallback)))
}
/// Get config
///
/// This combines config stored in permanent state and any runtime updates to the environment. This
/// is the canonical way to fetch config at runtime when you have Stack available.
pub fn get_config(engine_state: &EngineState, stack: &Stack) -> Config {
if let Some(mut config_record) = stack.get_env_var(engine_state, "config") {
config_record.into_config(engine_state.get_config()).0
} else {
engine_state.get_config().clone()
}
}
fn get_converted_value(
engine_state: &EngineState,
stack: &Stack,