From 76a79ba3e8660e9fdfd8e897c69065e79721545e Mon Sep 17 00:00:00 2001 From: Méven Car Date: Wed, 10 Sep 2025 15:44:29 +0200 Subject: dolphinview: position the focus after the last removed file Previously, the code could misposition the selection after removal if the last file in the view was removed and several files were selected. And since it didn't clear the selection, the previous selection influence the selection. Instead clear the selection and position only the focus, either on the next item after the last index, or the last item still in the view if the last item was removed. BUG: 504490 --- src/views/dolphinview.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d147a87f6..f48767e11 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1933,14 +1933,10 @@ void DolphinView::selectNextItem() Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed."); return; } - auto nextItem = lastSelectedIndex + 1; - if (nextItem >= itemsCount()) { - nextItem = lastSelectedIndex - selectedItemsCount(); - } - if (nextItem >= 0) { - selectionManager->setSelected(nextItem, 1); - selectionManager->beginAnchoredSelection(nextItem); - } + const auto nextItem = qMin(lastSelectedIndex + 1, itemsCount() - 1); + selectionManager->setCurrentItem(nextItem); + selectionManager->clearSelection(); + m_selectNextItem = false; } } -- cgit v1.3