LibLine: Avoid crashing if given empty suggestions

This commit is contained in:
AnotherTest 2020-04-15 18:26:11 +04:30 committed by Andreas Kling
parent 223a863c6d
commit 6b513ca97e
Notes: sideshowbarker 2024-07-19 07:34:56 +09:00

View File

@ -153,7 +153,10 @@ String Editor::get_line(const String& prompt)
auto reverse_tab = false;
auto increment_suggestion_index = [&] {
m_next_suggestion_index = (m_next_suggestion_index + 1) % m_suggestions.size();
if (m_suggestions.size())
m_next_suggestion_index = (m_next_suggestion_index + 1) % m_suggestions.size();
else
m_next_suggestion_index = 0;
};
auto decrement_suggestion_index = [&] {
if (m_next_suggestion_index == 0)