1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:37:45 +00:00

LibLine: Partially revert d8c5eec and remove unrelated code

This is a partial revert of d8c5eeceab
as it contained unrelated code that was committed accidentally,
which broke history on LibLine.
This commit is contained in:
Ali Mohammad Pur 2021-06-07 02:02:44 +04:30
parent 64754ba985
commit 4d5cdcc893

View file

@ -588,8 +588,10 @@ void Editor::interrupted()
m_is_editing = false;
restore();
m_notifier->set_enabled(false);
deferred_invoke([this](auto&) {
m_notifier = nullptr;
Core::EventLoop::current().quit(Retry);
});
}
void Editor::resized()
@ -623,14 +625,14 @@ void Editor::really_quit_event_loop()
m_returned_line = string;
m_notifier->set_enabled(false);
deferred_invoke([this](auto&) {
m_notifier = nullptr;
Core::EventLoop::current().quit(Exit);
});
}
auto Editor::get_line(const String& prompt) -> Result<String, Editor::Error>
{
OwnPtr<Core::EventLoop> event_loop;
do {
initialize();
m_is_editing = true;
@ -687,17 +689,16 @@ auto Editor::get_line(const String& prompt) -> Result<String, Editor::Error>
refresh_display();
if (!event_loop)
event_loop = make<Core::EventLoop>();
Core::EventLoop loop;
if (!m_notifier) {
m_notifier = Core::Notifier::construct(STDIN_FILENO, Core::Notifier::Read);
}
m_notifier->on_ready_to_read = [&] { try_update_once(); };
if (!m_incomplete_data.is_empty())
deferred_invoke([&](auto&) { try_update_once(); });
} while (event_loop->exec() == Retry);
if (loop.exec() == Retry)
return get_line(prompt);
return m_input_error.has_value() ? Result<String, Editor::Error> { m_input_error.value() } : Result<String, Editor::Error> { m_returned_line };
}