mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibLine: Avoid crashing if given empty suggestions
This commit is contained in:
parent
223a863c6d
commit
6b513ca97e
Notes:
sideshowbarker
2024-07-19 07:34:56 +09:00
Author: https://github.com/alimpfard
Commit: 6b513ca97e
Pull-request: https://github.com/SerenityOS/serenity/pull/1810
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 = [&] {
|
||||||
|
if (m_suggestions.size())
|
||||||
m_next_suggestion_index = (m_next_suggestion_index + 1) % 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