diff --git a/src/MainWindow.vala b/src/MainWindow.vala index eed2a58..c0f5dcd 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -322,18 +322,31 @@ public class Maps.MainWindow : Adw.ApplicationWindow { answer_count = 10 }; - loc_store.remove_all (); - var places = new List (); try { places = yield forward.search_async (search_cancellable); } catch (Error error) { warning (error.message); + loc_store.remove_all (); return; } + // Remove any old results that aren't in the new set + for (int i = 0; i < loc_store.n_items;) { + if (places.find ((Geocode.Place) loc_store.get_item (i)) == null) { + loc_store.remove (i); + continue; + } + + i++; + } + + // Add any missing results from the new set foreach (unowned var place in places) { - loc_store.append (place); + uint pos = -1; + if (!loc_store.find (place, out pos)) { + loc_store.append (place); + } } }