1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:04:57 +00:00

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
parent 8266e40b35
commit 76891ae45d

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());