mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
js: Convert s_history_path
to String and propagate errors
This commit is contained in:
parent
d18a7ca2dc
commit
698bcf4b4e
Notes:
sideshowbarker
2024-07-17 08:34:29 +09:00
Author: https://github.com/evansmal Commit: https://github.com/SerenityOS/serenity/commit/698bcf4b4e Pull-request: https://github.com/SerenityOS/serenity/pull/17306 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/linusg
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_disable_source_location_hints = false;
|
||||
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 bool s_fail_repl = false;
|
||||
|
||||
|
@ -614,6 +614,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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->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();
|
||||
|
||||
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) {
|
||||
if (!s_editor->is_editing())
|
||||
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) {
|
||||
|
@ -848,7 +850,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
};
|
||||
s_editor->on_tab_complete = move(complete);
|
||||
TRY(repl(*interpreter));
|
||||
s_editor->save_history(s_history_path);
|
||||
s_editor->save_history(s_history_path.to_deprecated_string());
|
||||
} else {
|
||||
interpreter = JS::Interpreter::create<ScriptObject>(*g_vm);
|
||||
auto& console_object = *interpreter->realm().intrinsics().console_object();
|
||||
|
|
Loading…
Reference in a new issue