Open a directory with 3 files starting with the same letter.
- Press this letter key twice
- The second file is selected
- Deselect the file with the mouse or using Esc
- Wait 1 second
- Press the same key again
The third file gets selected
The first file get selected
emit changeCurrentItem triggers KItemListController::slotChangeCurrentItem which calls in a row:
m_selectionManager->clearSelection(); m_selectionManager->setSelected(index, 1);
Triggering KItemListSelectionManager::SelectionChanged twice in a row and KItemListKeyboardSearchManager::slotSelectionChanged twice
The first time with : previous.isEmpty(): false current.isEmpty(): true previous.count(): 1 current.count(): 0 # deselect everything
Second time with : previous.isEmpty(): true current.isEmpty(): false previous.count(): 0 current.count(): 1 # select the new element
This caused a bug :
Let's you have three files : e1 e2 e3 in folder.
You type e then e and then e you expect the third file to be selected e3.
Without this check, the first file was selected and all subsequent e typing stays on the same file.
I have changed this to not be needed anymore adding KItemListSelectionManager::replaceSelection