mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
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.
This commit is contained in:
parent
28edafbfa6
commit
b71e504bba
1 changed files with 4 additions and 3 deletions
|
@ -41,7 +41,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
bool dump_ast = false;
|
bool dump_ast = false;
|
||||||
static Line::Editor editor {};
|
static OwnPtr<Line::Editor> editor;
|
||||||
|
|
||||||
String read_next_piece()
|
String read_next_piece()
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ String read_next_piece()
|
||||||
for (auto i = 0; i < level; ++i)
|
for (auto i = 0; i < level; ++i)
|
||||||
prompt_builder.append(" ");
|
prompt_builder.append(" ");
|
||||||
|
|
||||||
String line = editor.get_line(prompt_builder.build());
|
String line = editor->get_line(prompt_builder.build());
|
||||||
|
|
||||||
piece.append(line);
|
piece.append(line);
|
||||||
auto lexer = JS::Lexer(line);
|
auto lexer = JS::Lexer(line);
|
||||||
|
@ -194,7 +194,8 @@ int main(int argc, char** argv)
|
||||||
interpreter.global_object().put("global", &interpreter.global_object());
|
interpreter.global_object().put("global", &interpreter.global_object());
|
||||||
|
|
||||||
if (script_path == nullptr) {
|
if (script_path == nullptr) {
|
||||||
editor.initialize();
|
editor = make<Line::Editor>();
|
||||||
|
editor->initialize();
|
||||||
repl(interpreter);
|
repl(interpreter);
|
||||||
} else {
|
} else {
|
||||||
auto file = Core::File::construct(script_path);
|
auto file = Core::File::construct(script_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue