Bug 511664 - Find action algorithm leads to unexpected results
Summary: Find action algorithm leads to unexpected results
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: 25.08.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-05 08:54 UTC by tomashnyk
Modified: 2025-11-17 16:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
bad order (suggested order drawn) (640.80 KB, image/png)
2025-11-05 08:54 UTC, tomashnyk
Details
good order (also shows hte highlight bug) (566.55 KB, image/png)
2025-11-05 08:54 UTC, tomashnyk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tomashnyk 2025-11-05 08:54:08 UTC
Created attachment 186513 [details]
bad order (suggested order drawn)

I came accross this when I wanted to change sessions. I press F2 and start typing "session".

What happens:
I only get good results when I get to "sessio"

What I would expect:
I get good results already when I type "se" or "ses"

The thing is that the algorithm seem to be looking for finds *s*e*s*i*o*m, so for "se", it finds for example "kate upward Split viEw" (capitals emphasize what matches). It also finds "SourcEs: elm" [I think that is what is being matched - when part of the match is in the prefix, that is in "sources" in this case, the matched letters are not highlighted, which also sounds like a bug, should  report it separately? - it is visible on the second screenshot, where I made a red note about it].

That is all great and good, but I think some ordering of the results is in order. What I would suggest that the results be sorted by whether they contain "se", "ses", "sess" and so on as it is typed. I assume most people type a word they look for. If they were looking for "sources: elm", they could get that by typing "s e". Probably looking for "^ se" and then " se" first would also make sense, so we first match commands that either start with the string or that have a word that starts with the string. And while at it, per each such match, my orderly me might like it if they were sorted alphabetically (now the order seems random, I guess they are written as they are ordered in the menu?)
Comment 1 tomashnyk 2025-11-05 08:54:41 UTC
Created attachment 186514 [details]
good order (also shows hte highlight bug)
Comment 2 Waqar Ahmed 2025-11-06 07:47:45 UTC
We need to upstream some changes from Kate to the KFuzzyMatcher library.
Comment 3 Bug Janitor Service 2025-11-10 09:14:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/541
Comment 4 Christoph Cullmann 2025-11-17 16:50:37 UTC
Git commit d445210768f14140443ed0a8256868f93067803c by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 17/11/2025 at 16:50.
Pushed by cullmann into branch 'master'.

Update fuzzy matching logic changes from Kate

The algorithm has been updated in Kate, this patch upstreams all the
improvements. Most notably, it now tries to prefer sequential matches
and matches that happen at the start of a word

M  +3    -3    autotests/kfuzzymatchertest.cpp
M  +84   -48   src/lib/text/kfuzzymatcher.cpp

https://invent.kde.org/frameworks/kcoreaddons/-/commit/d445210768f14140443ed0a8256868f93067803c