LibWebView: Add a "Search with <engine>" autocomplete row

Synthesize an extra AutocompleteSuggestion at the top of the Search
Suggestions section whenever there is a configured search engine and
the typed query is not URL-shaped.

Use the query as the row's primary text, carry a "Search with <engine>"
subtitle, and render that subtitle in the AppKit and Qt popups so the
explicit search fallback stays visible and readable even when history
fills the list.
This commit is contained in:
Andreas Kling
2026-04-16 09:36:33 +02:00
committed by Andreas Kling
parent bb9f789eae
commit 586da4e610
Notes: github-actions[bot] 2026-04-16 19:02:36 +00:00
4 changed files with 60 additions and 12 deletions

View File

@@ -696,6 +696,7 @@ static NSImage* literal_url_suggestion_icon()
auto const& suggestion = m_suggestions[row_model.suggestion_index];
auto* suggestion_text = Ladybird::string_to_ns_string(suggestion.text);
auto* title_text = suggestion.title.has_value() ? Ladybird::string_to_ns_string(*suggestion.title) : nil;
auto* secondary_text = suggestion.subtitle.has_value() ? Ladybird::string_to_ns_string(*suggestion.subtitle) : suggestion_text;
auto* favicon = [self.suggestion_icons objectForKey:suggestion_text];
auto* icon = suggestion.source == WebView::AutocompleteSuggestionSource::LiteralURL
? literal_url_suggestion_icon()
@@ -750,7 +751,7 @@ static NSImage* literal_url_suggestion_icon()
primary_text_height)];
}
[view.url_text_field setStringValue:suggestion_text];
[view.url_text_field setStringValue:(title_text != nil ? secondary_text : suggestion_text)];
return view;
}