Use append_history instead of save_history to preserve existing history (#3314)
This commit is contained in:
parent
004230d02d
commit
a92ff57270
|
@ -342,7 +342,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
|
||||||
LineResult::Success(line) => {
|
LineResult::Success(line) => {
|
||||||
if options.save_history && !line.trim().is_empty() {
|
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.append_history(&history_path);
|
||||||
}
|
}
|
||||||
maybe_print_errors(&context, Text::from(session_text.clone()));
|
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 => {
|
LineResult::ClearHistory => {
|
||||||
if options.save_history {
|
if options.save_history {
|
||||||
rl.clear_history();
|
rl.clear_history();
|
||||||
let _ = rl.save_history(&history_path);
|
let _ = rl.append_history(&history_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LineResult::Error(line, err) => {
|
LineResult::Error(line, err) => {
|
||||||
if options.save_history && !line.trim().is_empty() {
|
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.append_history(&history_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
context
|
context
|
||||||
|
@ -390,7 +390,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box<dyn E
|
||||||
|
|
||||||
if ctrlcbreak {
|
if ctrlcbreak {
|
||||||
if options.save_history {
|
if options.save_history {
|
||||||
let _ = rl.save_history(&history_path);
|
let _ = rl.append_history(&history_path);
|
||||||
}
|
}
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else {
|
} 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
|
// we are ok if we can not save history
|
||||||
if options.save_history {
|
if options.save_history {
|
||||||
let _ = rl.save_history(&history_path);
|
let _ = rl.append_history(&history_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user