UI/Qt: Limit number of autocomplete results to 6
This commit is contained in:
parent
c36a49b61e
commit
944dbfdc97
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/944dbfdc97 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/299
1 changed files with 3 additions and 0 deletions
|
@ -124,8 +124,11 @@ ErrorOr<void> AutoComplete::got_network_response(QNetworkReply* reply)
|
|||
return Error::from_string_view("Invalid engine name"sv);
|
||||
}
|
||||
|
||||
constexpr size_t MAX_AUTOCOMPLETE_RESULTS = 6;
|
||||
if (results.is_empty()) {
|
||||
results.append(m_query);
|
||||
} else if (results.size() > MAX_AUTOCOMPLETE_RESULTS) {
|
||||
results.shrink(MAX_AUTOCOMPLETE_RESULTS);
|
||||
}
|
||||
|
||||
m_auto_complete_model->replace_suggestions(move(results));
|
||||
|
|
Loading…
Add table
Reference in a new issue