Bug 501851

Summary: Type-ahead navigation does not find filenames beginning with the same character repeated twice
Product: [Applications] dolphin Reporter: adrruiz
Component: view-engine: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: dolphin-bugs-null, john.kizer
Priority: NOR    
Version First Reported In: 24.08.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description adrruiz 2025-03-21 21:58:55 UTC
SUMMARY
In a folder containing many files, some names are numeric, for example, 01.txt, 02.txt, 03.txt, etc. When typing the file name to quickly navigate to it, in the case of file 44.txt what Dolphin does with the first press of "4" is go to 40.txt and with the second press of "4" it goes to 41.txt and not 44.txt. Each time I press the same key it only advances one file in the list of those that begin with 4*.txt and does not take the press as the second character of the file name, in this case 4"4".txt

STEPS TO REPRODUCE
1. Open Dolphin
2. go to a folder containing many files, some names are numeric, for example, 01.txt, 02.txt, 03.txt, etc. 
3. go to directo to 44.txt file

OBSERVED RESULT

EXPECTED RESULT
go to 41.txt instead

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 24.10
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION
Comment 1 John Kizer 2025-04-08 03:27:11 UTC
Hi - I can reproduce on Fedora KDE 41, Dolphin 24.12.3. Thanks!
Comment 2 Bug Janitor Service 2025-10-31 09:47:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/1085
Comment 3 Méven 2025-11-10 08:38:36 UTC
Git commit 3858afbfa4f2f60cc33f39a471d36a1e1a3514c7 by Méven Car, on behalf of weinan li.
Committed on 10/11/2025 at 08:38.
Pushed by meven into branch 'master'.

dolphin: improve keyboard search behavior for repeated characters

The original keyboard search implementation had a limitation when dealing with files containing repeated characters like 44.txt. When typing 44, it would trigger rapid navigation to the next item starting with 4 instead of matching the full string 44.

This patch introduces a smarter search strategy:
1. First attempt full string matching for exact file names
2. If full match fails and user is typing repeating characters, fall back to rapid navigation using either:
   - Last successful search string (for extended searches like 444 -> 4444)
   - First character only (original rapid navigation behavior)

The changes include:
- Modified changeCurrentItem signal to include a found parameter for search result feedback
- Added m_lastSuccessfulSearch to track successful searches for better fallback behavior
- Used Qt::DirectConnection to ensure synchronous execution for immediate result feedback

This provides better user experience when searching for files with repeated characters while maintaining the rapid navigation feature for quick browsing.

M  +4    -2    src/kitemviews/kitemlistcontroller.cpp
M  +1    -1    src/kitemviews/kitemlistcontroller.h
M  +27   -11   src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
M  +2    -1    src/kitemviews/private/kitemlistkeyboardsearchmanager.h
M  +109  -38   src/tests/kitemlistkeyboardsearchmanagertest.cpp

https://invent.kde.org/system/dolphin/-/commit/3858afbfa4f2f60cc33f39a471d36a1e1a3514c7