]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
Fix crash when opening new tab with search
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index 5a396de61fd48f83be3144a771a36eea19fce194..2f1bdc551df3bc071094e415eed870b805d4123a 100644 (file)
@@ -521,9 +521,9 @@ void KItemListController::slotChangeCurrentItem(const QString &text, bool search
         return;
     }
     int index;
-    if (searchFromNextItem) {
-        const int currentIndex = m_selectionManager->currentItem();
-        index = m_model->indexForKeyboardSearch(text, (currentIndex + 1) % m_model->count());
+    // In selection mode, always use the current (underlined) item, or the next item, for search start position.
+    if (m_selectionBehavior == NoSelection || m_selectionMode || m_selectionManager->hasSelection()) {
+        index = m_model->indexForKeyboardSearch(text, searchFromNextItem ? m_selectionManager->currentItem() + 1 : m_selectionManager->currentItem());
     } else {
         index = m_model->indexForKeyboardSearch(text, 0);
     }