mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 23:49:44 +01:00
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) => {
|
||||
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(())
|
||||
|
Loading…
Reference in New Issue
Block a user