diff --git a/goalc/compiler/Compiler.cpp b/goalc/compiler/Compiler.cpp index e210a5009c..8aa6781d37 100644 --- a/goalc/compiler/Compiler.cpp +++ b/goalc/compiler/Compiler.cpp @@ -71,6 +71,10 @@ Compiler::~Compiler() { } } +void Compiler::save_repl_history() { + m_repl->save_history(); +} + void Compiler::print_to_repl(const std::string_view& str) { m_repl->print_to_repl(str); } diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 2913d5d434..03ec68db59 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -30,6 +30,7 @@ class Compiler { public: Compiler(const std::string& user_profile = "#f", std::unique_ptr repl = nullptr); ~Compiler(); + void save_repl_history(); void print_to_repl(const std::string_view& str); std::string get_prompt(); std::string get_repl_input(); diff --git a/goalc/main.cpp b/goalc/main.cpp index 0f5e6bf298..600c335349 100644 --- a/goalc/main.cpp +++ b/goalc/main.cpp @@ -127,6 +127,9 @@ int main(int argc, char** argv) { if (status == ReplStatus::WANT_RELOAD) { fmt::print("Reloading compiler...\n"); std::lock_guard lock(compiler_mutex); + if (compiler) { + compiler->save_repl_history(); + } compiler = std::make_unique(username, std::make_unique()); status = ReplStatus::OK; }