diff options
| author | Yifan Zhu <[email protected]> | 2025-02-20 10:35:06 -0800 |
|---|---|---|
| committer | Yifan Zhu <[email protected]> | 2025-02-22 14:26:57 -0800 |
| commit | b4dedc0d0df2c8b191192476d7787630180e51c7 (patch) | |
| tree | 095c84eee1c8e484b8d1ea1a568790c1aa6704fa /src/kitemviews/kitemlistcontroller.cpp | |
| parent | 79d1f25ad14b1626c64d7f25c2fa16da0e2b2737 (diff) | |
kitemlistkeyboardsearchmanager: smarter search start position
Search from the next position for new search and special repeated key search.
Otherwise search from the current position, which is current selected item if
something is selected or in selection mode, and 0 (the beginning) otherwise.
Test plan:
- create directory with files ab1, ab2, and ab3
- click ab2, and press escape to deselect
- type ab; verify that ab1 is selected
- wait a while, type ab again, verify that ab2 is selected
- wait a while, type ab again, verify that ab3 is selected
- click ab1, type ab, verify that ab2 is selected
BUG: 422951
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 5a396de61..2f1bdc551 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -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); } |
