From ba1ff4cf6c6c88b6a17931b86c849140d452045f Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 23 Dec 2021 13:59:00 -0600 Subject: [PATCH] add configuration of maximum history size (#563) --- crates/nu-protocol/src/config.rs | 5 +++++ src/main.rs | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/nu-protocol/src/config.rs b/crates/nu-protocol/src/config.rs index 0bcaf51b3..e61f6a7d6 100644 --- a/crates/nu-protocol/src/config.rs +++ b/crates/nu-protocol/src/config.rs @@ -52,6 +52,7 @@ pub struct Config { pub use_ansi_coloring: bool, pub env_conversions: HashMap, 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()?; + } _ => {} } } diff --git a/src/main.rs b/src/main.rs index fdeb165dd..7f4634caf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {