mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
js: Convert s_history_path
to String and propagate errors
This commit is contained in:
parent
d18a7ca2dc
commit
698bcf4b4e
1 changed files with 6 additions and 4 deletions
|
@ -77,7 +77,7 @@ static bool s_print_last_result = false;
|
||||||
static bool s_strip_ansi = false;
|
static bool s_strip_ansi = false;
|
||||||
static bool s_disable_source_location_hints = false;
|
static bool s_disable_source_location_hints = false;
|
||||||
static RefPtr<Line::Editor> s_editor;
|
static RefPtr<Line::Editor> s_editor;
|
||||||
static DeprecatedString s_history_path = DeprecatedString::formatted("{}/.js-history", Core::StandardPaths::home_directory());
|
static String s_history_path = String {};
|
||||||
static int s_repl_line_level = 0;
|
static int s_repl_line_level = 0;
|
||||||
static bool s_fail_repl = false;
|
static bool s_fail_repl = false;
|
||||||
|
|
||||||
|
@ -614,6 +614,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
bool syntax_highlight = !disable_syntax_highlight;
|
bool syntax_highlight = !disable_syntax_highlight;
|
||||||
|
|
||||||
|
s_history_path = TRY(String::formatted("{}/.js-history", Core::StandardPaths::home_directory()));
|
||||||
|
|
||||||
g_vm = JS::VM::create();
|
g_vm = JS::VM::create();
|
||||||
g_vm->enable_default_host_import_module_dynamically_hook();
|
g_vm->enable_default_host_import_module_dynamically_hook();
|
||||||
|
|
||||||
|
@ -648,12 +650,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto& global_environment = interpreter->realm().global_environment();
|
auto& global_environment = interpreter->realm().global_environment();
|
||||||
|
|
||||||
s_editor = Line::Editor::construct();
|
s_editor = Line::Editor::construct();
|
||||||
s_editor->load_history(s_history_path);
|
s_editor->load_history(s_history_path.to_deprecated_string());
|
||||||
|
|
||||||
signal(SIGINT, [](int) {
|
signal(SIGINT, [](int) {
|
||||||
if (!s_editor->is_editing())
|
if (!s_editor->is_editing())
|
||||||
sigint_handler();
|
sigint_handler();
|
||||||
s_editor->save_history(s_history_path);
|
s_editor->save_history(s_history_path.to_deprecated_string());
|
||||||
});
|
});
|
||||||
|
|
||||||
s_editor->on_display_refresh = [syntax_highlight](Line::Editor& editor) {
|
s_editor->on_display_refresh = [syntax_highlight](Line::Editor& editor) {
|
||||||
|
@ -848,7 +850,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
};
|
};
|
||||||
s_editor->on_tab_complete = move(complete);
|
s_editor->on_tab_complete = move(complete);
|
||||||
TRY(repl(*interpreter));
|
TRY(repl(*interpreter));
|
||||||
s_editor->save_history(s_history_path);
|
s_editor->save_history(s_history_path.to_deprecated_string());
|
||||||
} else {
|
} else {
|
||||||
interpreter = JS::Interpreter::create<ScriptObject>(*g_vm);
|
interpreter = JS::Interpreter::create<ScriptObject>(*g_vm);
|
||||||
auto& console_object = *interpreter->realm().intrinsics().console_object();
|
auto& console_object = *interpreter->realm().intrinsics().console_object();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue