From 5f188bd4031ddf64792957e34d71562cf34aa2c1 Mon Sep 17 00:00:00 2001 From: Khalid Abu Shawarib Date: Sun, 21 May 2023 17:17:58 +0000 Subject: [PATCH] placessidebar: Don't refresh when there's selection Stop sidebar from reopening location if we are already inside the location. This prevents it from refreshing when there's selection. The reason this happens is because it's trying to honor command line selection parameters behaviour by opening a new tab/window when location is already opened but has different selection than specified. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2960 --- src/gtk/nautilusgtkplacessidebar.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c index 128054ddae..f270588bbe 100644 --- a/src/gtk/nautilusgtkplacessidebar.c +++ b/src/gtk/nautilusgtkplacessidebar.c @@ -2146,6 +2146,9 @@ open_row (NautilusGtkSidebarRow *row, GVolume *volume; NautilusGtkPlacesPlaceType place_type; NautilusGtkPlacesSidebar *sidebar; + g_autofree gchar *old_uri = NULL; + gboolean open_new_slot = open_flags & NAUTILUS_GTK_PLACES_OPEN_NEW_TAB + || open_flags & NAUTILUS_GTK_PLACES_OPEN_NEW_WINDOW; g_object_get (row, "sidebar", &sidebar, @@ -2155,7 +2158,13 @@ open_row (NautilusGtkSidebarRow *row, "volume", &volume, NULL); - if (place_type == NAUTILUS_GTK_PLACES_OTHER_LOCATIONS) + old_uri = g_file_get_uri (sidebar->current_location); + + if ((g_strcmp0 (old_uri, uri) == 0) && !open_new_slot) + { + /* Location already open. Do nothing. */ + } + else if (place_type == NAUTILUS_GTK_PLACES_OTHER_LOCATIONS) { emit_show_other_locations_with_flags (sidebar, open_flags); } -- GitLab