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.
This commit is contained in:
Marc Schreiber 2021-04-09 02:01:31 +02:00 committed by GitHub
parent a7274115d0
commit 111ad868a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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