UI/Qt: Limit number of autocomplete results to 6

This commit is contained in:
Tim Ledbetter 2024-06-27 13:47:40 +01:00 committed by Andreas Kling
parent c36a49b61e
commit 944dbfdc97

View File

@ -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));