Do not store whitespace entries into history () ()

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.
This commit is contained in:
Marc Schreiber
2021-04-09 02:01:31 +02:00
committed by GitHub
parent a7274115d0
commit 111ad868a7

@ -319,7 +319,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
match line { match line {
LineResult::Success(line) => { LineResult::Success(line) => {
if options.save_history { if options.save_history && !line.trim().is_empty() {
rl.add_history_entry(&line); rl.add_history_entry(&line);
let _ = rl.save_history(&history_path); let _ = rl.save_history(&history_path);
} }
@ -334,7 +334,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
} }
LineResult::Error(line, err) => { LineResult::Error(line, err) => {
if options.save_history { if options.save_history && !line.trim().is_empty() {
rl.add_history_entry(&line); rl.add_history_entry(&line);
let _ = rl.save_history(&history_path); let _ = rl.save_history(&history_path);
} }