1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 12:48:11 +00:00

Shell: Reset the custom Shell keybinds before calling Editor::get_line()

Fixes #19301.
This commit is contained in:
Ali Mohammad Pur 2023-06-11 16:24:54 +03:30 committed by Ali Mohammad Pur
parent 36153136c4
commit 1696411f66
2 changed files with 15 additions and 8 deletions

View file

@ -2075,11 +2075,25 @@ bool Shell::has_history_event(StringView source)
return visitor.has_history_event; 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() bool Shell::read_single_line()
{ {
while (true) { while (true) {
restore_ios(); restore_ios();
bring_cursor_to_beginning_of_a_line(); bring_cursor_to_beginning_of_a_line();
m_editor->initialize();
setup_keybinds();
auto line_result = m_editor->get_line(prompt()); auto line_result = m_editor->get_line(prompt());
if (line_result.is_error()) { if (line_result.is_error()) {
@ -2292,14 +2306,6 @@ Shell::Shell(Line::Editor& editor, bool attempt_interactive, bool posix_mode)
cache_path(); 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); start_timer(3000);
} }

View file

@ -109,6 +109,7 @@ public:
void set_live_formatting(bool value) { m_should_format_live = value; } void set_live_formatting(bool value) { m_should_format_live = value; }
void setup_signals(); void setup_signals();
void setup_keybinds();
struct SourcePosition { struct SourcePosition {
DeprecatedString source_file; DeprecatedString source_file;