diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index e49a6a9da6..8e6494919e 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -214,8 +214,12 @@ int PlacesItemModel::closestItem(const QUrl& url) const for (int i = 0; i < count(); ++i) { const QUrl itemUrl = placesItem(i)->url(); - if (itemUrl.isParentOf(url)) { - const int length = itemUrl.toDisplayString().length(); + if (url == itemUrl) { + // We can't find a closer one, so stop here. + foundIndex = i; + break; + } else if (itemUrl.isParentOf(url)) { + const int length = itemUrl.path().length(); if (length > maxLength) { foundIndex = i; maxLength = length;