mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:17:41 +00:00
LibLine: Avoid crashing if given empty suggestions
This commit is contained in:
parent
223a863c6d
commit
6b513ca97e
1 changed files with 4 additions and 1 deletions
|
@ -153,7 +153,10 @@ String Editor::get_line(const String& prompt)
|
||||||
|
|
||||||
auto reverse_tab = false;
|
auto reverse_tab = false;
|
||||||
auto increment_suggestion_index = [&] {
|
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 = [&] {
|
auto decrement_suggestion_index = [&] {
|
||||||
if (m_next_suggestion_index == 0)
|
if (m_next_suggestion_index == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue