Save history on exit

This commit is contained in:
Piotr Rzysko 2025-04-28 08:35:04 +02:00
parent bde2d4f0a3
commit 33d230771f

View file

@ -558,11 +558,13 @@ impl Limbo {
}
Ok(cmd) => match cmd.command {
Command::Exit(args) => {
self.save_history();
std::process::exit(args.code);
}
Command::Quit => {
let _ = self.writeln("Exiting Limbo SQL Shell.");
let _ = self.close_conn();
self.save_history();
std::process::exit(0)
}
Command::Open(args) => {
@ -1008,12 +1010,16 @@ impl Limbo {
Ok(input)
}
}
}
impl Drop for Limbo {
fn drop(&mut self) {
fn save_history(&mut self) {
if let Some(rl) = &mut self.rl {
let _ = rl.save_history(HISTORY_FILE.as_path());
}
}
}
impl Drop for Limbo {
fn drop(&mut self) {
self.save_history()
}
}