js: Save REPL history when exiting interpreter with exit()

Previously, we only saved the REPL history when the interpreter was
shutdown with a signal. This change ensures that we save the history
when a user uses `exit()`.
This commit is contained in:
Evan Smal 2023-02-10 11:02:52 -05:00 committed by Linus Groh
commit 76891ae45d
Notes: sideshowbarker 2024-07-18 00:41:35 +09:00

View file

@ -421,6 +421,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::save_to_file)
JS_DEFINE_NATIVE_FUNCTION(ReplObject::exit_interpreter)
{
s_editor->save_history(s_history_path.to_deprecated_string());
if (!vm.argument_count())
exit(0);
exit(TRY(vm.argument(0).to_number(vm)).as_double());