Skip to content

Commit 56352c8

Browse files
committed
Save REPL history when resetting
1 parent eb36786 commit 56352c8

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

quiver-cli/src/repl_cli.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,25 @@ impl ReplCli {
118118
return false;
119119
}
120120

121-
["!"] => match Self::new() {
122-
Ok(new_repl) => {
123-
*self = new_repl;
124-
println!("{}", "Environment reset".bright_black());
121+
["!"] => {
122+
// Save history before resetting
123+
if let Err(e) = self.editor.save_history(HISTORY_FILE) {
124+
eprintln!(
125+
"{}",
126+
format!("Warning: Failed to save history: {}", e).bright_black()
127+
);
125128
}
126-
Err(e) => {
127-
eprintln!("{}", format!("Error resetting environment: {}", e).red());
129+
130+
match Self::new() {
131+
Ok(new_repl) => {
132+
*self = new_repl;
133+
println!("{}", "Environment reset".bright_black());
134+
}
135+
Err(e) => {
136+
eprintln!("{}", format!("Error resetting environment: {}", e).red());
137+
}
128138
}
129-
},
139+
}
130140

131141
["v"] => {
132142
self.list_variables();

0 commit comments

Comments
 (0)