Commit 1fc30f4d authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

Fixes bug where deleting local history ZPS with Shit+Del doesn't update UI

Deleting suggestions with Shift+Del (as opposed to right click and choosing
delete from the dropdown menu) does not invoke Start() on the provider.
Therefore, the list of autocomplete matches were not being updated. This
fixes that bug by immediately deleting the match from the list of matches.

Bug: 996516
Change-Id: If37a59d80b68a9f64a66140328a49549ef8ae53d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832983
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702225}
parent 82f9c087
......@@ -234,6 +234,11 @@ void LocalHistoryZeroSuggestProvider::DeleteMatch(
// Prevent the deleted suggestion from being resuggested until the
// corresponding URLs are asynchronously deleted.
deleted_suggestions_set_.insert(match.contents);
// Immediately update the list of matches to reflect the match was deleted.
base::EraseIf(matches_, [&](const auto& item) {
return match.contents == item.contents;
});
}
LocalHistoryZeroSuggestProvider::LocalHistoryZeroSuggestProvider(
......
......@@ -328,8 +328,11 @@ TEST_F(LocalHistoryZeroSuggestProviderTest, Delete) {
provider_->DeleteMatch(provider_->matches()[0]);
// Make sure the deletion takes effect immediately in the provider even before
// the history service asynchronously performs the deletion.
// Make sure the deletion takes effect immediately in the provider before the
// history service asynchronously performs the deletion or even before the
// provider is started again.
ExpectMatches({});
StartProviderAndWaitUntilDone();
ExpectMatches({});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment