Use append_history instead of save_history to preserve existing history (#3314)

This commit is contained in:
Martin Mauch 2021-04-14 20:20:25 +02:00 committed by GitHub
parent 004230d02d
commit a92ff57270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,7 +342,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
LineResult::Success(line) => {
if options.save_history && !line.trim().is_empty() {
rl.add_history_entry(&line);
let _ = rl.save_history(&history_path);
let _ = rl.append_history(&history_path);
}
maybe_print_errors(&context, Text::from(session_text.clone()));
}
@ -350,14 +350,14 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
LineResult::ClearHistory => {
if options.save_history {
rl.clear_history();
let _ = rl.save_history(&history_path);
let _ = rl.append_history(&history_path);
}
}
LineResult::Error(line, err) => {
if options.save_history && !line.trim().is_empty() {
rl.add_history_entry(&line);
let _ = rl.save_history(&history_path);
let _ = rl.append_history(&history_path);
}
context
@ -390,7 +390,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
if ctrlcbreak {
if options.save_history {
let _ = rl.save_history(&history_path);
let _ = rl.append_history(&history_path);
}
std::process::exit(0);
} else {
@ -416,7 +416,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
// we are ok if we can not save history
if options.save_history {
let _ = rl.save_history(&history_path);
let _ = rl.append_history(&history_path);
}
Ok(())