From b71e504bba16f1d58302b794fc7ff463cdac5dda Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 31 Mar 2020 19:00:20 +0200 Subject: [PATCH] js: Don't construct a Line::Editor unless we're going into the REPL Otherwise the Line::Editor will try to reset termios on exit, which can have unpleasant effects. --- Userland/js.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/js.cpp b/Userland/js.cpp index dca12fa251..140c8e45bd 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -41,7 +41,7 @@ #include bool dump_ast = false; -static Line::Editor editor {}; +static OwnPtr editor; String read_next_piece() { @@ -55,7 +55,7 @@ String read_next_piece() for (auto i = 0; i < level; ++i) prompt_builder.append(" "); - String line = editor.get_line(prompt_builder.build()); + String line = editor->get_line(prompt_builder.build()); piece.append(line); auto lexer = JS::Lexer(line); @@ -194,7 +194,8 @@ int main(int argc, char** argv) interpreter.global_object().put("global", &interpreter.global_object()); if (script_path == nullptr) { - editor.initialize(); + editor = make(); + editor->initialize(); repl(interpreter); } else { auto file = Core::File::construct(script_path);