forked from extern/nushell
add configuration of maximum history size (#563)
This commit is contained in:
parent
5c83f4d405
commit
ba1ff4cf6c
@ -52,6 +52,7 @@ pub struct Config {
|
||||
pub use_ansi_coloring: bool,
|
||||
pub env_conversions: HashMap<String, EnvConversion>,
|
||||
pub edit_mode: String,
|
||||
pub max_history_size: i64,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -69,6 +70,7 @@ impl Default for Config {
|
||||
use_ansi_coloring: true,
|
||||
env_conversions: HashMap::new(), // TODO: Add default conversoins
|
||||
edit_mode: "emacs".into(),
|
||||
max_history_size: 1000,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,6 +183,9 @@ impl Value {
|
||||
"edit_mode" => {
|
||||
config.edit_mode = value.as_string()?;
|
||||
}
|
||||
"max_history_size" => {
|
||||
config.max_history_size = value.as_i64()?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -364,8 +364,11 @@ fn main() -> Result<()> {
|
||||
),
|
||||
))
|
||||
.with_history(Box::new(
|
||||
FileBackedHistory::with_file(1000, history_path.clone())
|
||||
.into_diagnostic()?,
|
||||
FileBackedHistory::with_file(
|
||||
config.max_history_size as usize,
|
||||
history_path.clone(),
|
||||
)
|
||||
.into_diagnostic()?,
|
||||
))
|
||||
.into_diagnostic()?
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user