mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibLine: Handle read events serially
Previously LibLine accepted read callbacks while it was in the process of reading input, this wasn't an issue as no async code was being executed up until the Shell autocompletion came along. Simply defer input processing while processing input to avoid causing problems. Fixes #13280.
This commit is contained in:
parent
5e541aaebd
commit
f6afb70b07
Notes:
sideshowbarker
2024-07-17 16:39:13 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/f6afb70b07 Pull-request: https://github.com/SerenityOS/serenity/pull/13296 Issue: https://github.com/SerenityOS/serenity/issues/13280 Issue: https://github.com/SerenityOS/serenity/issues/13281 Reviewed-by: https://github.com/linusg ✅
|
@ -791,6 +791,13 @@ void Editor::handle_interrupt_event()
|
|||
|
||||
void Editor::handle_read_event()
|
||||
{
|
||||
if (m_prohibit_input_processing) {
|
||||
m_have_unprocessed_read_event = true;
|
||||
return;
|
||||
}
|
||||
|
||||
auto prohibit_scope = prohibit_input();
|
||||
|
||||
char keybuf[16];
|
||||
ssize_t nread = 0;
|
||||
|
||||
|
|
|
@ -241,6 +241,20 @@ public:
|
|||
|
||||
const Utf32View buffer_view() const { return { m_buffer.data(), m_buffer.size() }; }
|
||||
|
||||
auto prohibit_input()
|
||||
{
|
||||
auto previous_value = m_prohibit_input_processing;
|
||||
m_prohibit_input_processing = true;
|
||||
m_have_unprocessed_read_event = false;
|
||||
return ScopeGuard {
|
||||
[this, previous_value] {
|
||||
m_prohibit_input_processing = previous_value;
|
||||
if (!m_prohibit_input_processing && m_have_unprocessed_read_event)
|
||||
handle_read_event();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
explicit Editor(Configuration configuration = Configuration::from_config());
|
||||
|
||||
|
@ -500,6 +514,8 @@ private:
|
|||
Vector<int, 2> m_signal_handlers;
|
||||
|
||||
bool m_is_editing { false };
|
||||
bool m_prohibit_input_processing { false };
|
||||
bool m_have_unprocessed_read_event { false };
|
||||
|
||||
Configuration m_configuration;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue