Omnibox: Don't Cache Calculator Results
Don't cache calculate results, else it's possible we'll still be
displaying a calculate result after the user types more, and that
calculate result may be incorrect.
Tested by setting the suggest delay to something long (1 second).
Typed 1+2.
Waited until the suggestions (including the =3) were displayed.
Typed +3.
Noticed that all suggestions remain, include the =3 (which is
incorrect given the current input), until the next suggest
request is returned.
After this change, this above repro steps no longer work.
BUG=550659
Review URL: https://codereview.chromium.org/1413813008
Cr-Commit-Position: refs/heads/master@{#358985}
diff --git a/components/omnibox/browser/search_provider.cc b/components/omnibox/browser/search_provider.cc
index 926c3df..914aeb5 100644
--- a/components/omnibox/browser/search_provider.cc
+++ b/components/omnibox/browser/search_provider.cc
@@ -215,8 +215,13 @@
if (!minimal_changes) {
for (SearchSuggestionParser::SuggestResults::iterator sug_it =
results->suggest_results.begin();
- sug_it != results->suggest_results.end(); ++sug_it) {
- sug_it->set_received_after_last_keystroke(false);
+ sug_it != results->suggest_results.end(); ) {
+ if (sug_it->type() == AutocompleteMatchType::CALCULATOR) {
+ sug_it = results->suggest_results.erase(sug_it);
+ } else {
+ sug_it->set_received_after_last_keystroke(false);
+ ++sug_it;
+ }
}
for (SearchSuggestionParser::NavigationResults::iterator nav_it =
results->navigation_results.begin();