Pārlūkot izejas kodu

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.
Andreas Kling 5 gadi atpakaļ
vecāks
revīzija
b71e504bba
1 mainītis faili ar 4 papildinājumiem un 3 dzēšanām
  1. 4 3
      Userland/js.cpp

+ 4 - 3
Userland/js.cpp

@@ -41,7 +41,7 @@
 #include <stdio.h>
 
 bool dump_ast = false;
-static Line::Editor editor {};
+static OwnPtr<Line::Editor> 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<Line::Editor>();
+        editor->initialize();
         repl(interpreter);
     } else {
         auto file = Core::File::construct(script_path);