goalc: save repl history when the compiler reloads

This commit is contained in:
Tyler Wilding
2022-05-01 17:58:28 -04:00
parent f7c30a4084
commit 1b6baa5867
3 changed files with 8 additions and 0 deletions
+4
View File
@@ -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);
}
+1
View File
@@ -30,6 +30,7 @@ class Compiler {
public:
Compiler(const std::string& user_profile = "#f", std::unique_ptr<ReplWrapper> 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();
+3
View File
@@ -127,6 +127,9 @@ int main(int argc, char** argv) {
if (status == ReplStatus::WANT_RELOAD) {
fmt::print("Reloading compiler...\n");
std::lock_guard<std::mutex> lock(compiler_mutex);
if (compiler) {
compiler->save_repl_history();
}
compiler = std::make_unique<Compiler>(username, std::make_unique<ReplWrapper>());
status = ReplStatus::OK;
}