From 111ad868a7bc9a5af1c9913ecc8fff444d45597c Mon Sep 17 00:00:00 2001 From: Marc Schreiber Date: Fri, 9 Apr 2021 02:01:31 +0200 Subject: [PATCH] Do not store whitespace entries into history (#3019) (#3286) Before storing an entry into the history nushell will check if the entry consists only of whitespaces and if so, it does not store it in the history and this avoids newline repetition when user is navigating in the history. --- crates/nu-cli/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 6f41176718..c13dc2abfb 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -319,7 +319,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box { - if options.save_history { + if options.save_history && !line.trim().is_empty() { rl.add_history_entry(&line); let _ = rl.save_history(&history_path); } @@ -334,7 +334,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box { - if options.save_history { + if options.save_history && !line.trim().is_empty() { rl.add_history_entry(&line); let _ = rl.save_history(&history_path); }