From b45e697e6407a71fbe5edaf5c9aa348f92bbcd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 15 Jul 2025 11:54:10 -0700 Subject: [PATCH 1/2] MainWindow: add and remove search results instead of clearing the list --- src/MainWindow.vala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 310b28b..78361d9 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -259,12 +259,23 @@ public class Maps.MainWindow : Adw.ApplicationWindow { places = yield forward.search_async (search_cancellable); } catch (Error error) { warning (error.message); + loc_store.remove_all (); return; } - loc_store.remove_all (); + // Remove any old results that aren't in the new set + for (int i = 0; i < loc_store.n_items; i++) { + if (places.find ((Geocode.Place) loc_store.get_item (i)) == null) { + loc_store.remove (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); + } } } From 5ffc3a2492223141e6165a3f98943c7728ed8888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 16 Jul 2025 10:47:21 -0700 Subject: [PATCH 2/2] Only increase index when we don't remove --- src/MainWindow.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 9bfdf71..a6b02dd 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -283,10 +283,13 @@ public class Maps.MainWindow : Adw.ApplicationWindow { } // Remove any old results that aren't in the new set - for (int i = 0; i < loc_store.n_items; i++) { + 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