diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 02157fa0eb..8b92633880 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -2075,11 +2075,25 @@ bool Shell::has_history_event(StringView source) return visitor.has_history_event; } +void Shell::setup_keybinds() +{ + m_editor->register_key_input_callback('\n', [this](Line::Editor& editor) { + auto ast = parse(editor.line(), false); + if (ast && ast->is_syntax_error() && ast->syntax_error_node().is_continuable()) + return true; + + return EDITOR_INTERNAL_FUNCTION(finish)(editor); + }); +} + bool Shell::read_single_line() { while (true) { restore_ios(); bring_cursor_to_beginning_of_a_line(); + m_editor->initialize(); + setup_keybinds(); + auto line_result = m_editor->get_line(prompt()); if (line_result.is_error()) { @@ -2292,14 +2306,6 @@ Shell::Shell(Line::Editor& editor, bool attempt_interactive, bool posix_mode) cache_path(); } - m_editor->register_key_input_callback('\n', [this](Line::Editor& editor) { - auto ast = parse(editor.line(), false); - if (ast && ast->is_syntax_error() && ast->syntax_error_node().is_continuable()) - return true; - - return EDITOR_INTERNAL_FUNCTION(finish)(editor); - }); - start_timer(3000); } diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index b425333183..04a2ccce8c 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -109,6 +109,7 @@ public: void set_live_formatting(bool value) { m_should_format_live = value; } void setup_signals(); + void setup_keybinds(); struct SourcePosition { DeprecatedString source_file;