Penalize matches in the shared project prefix path
ClosedPublic

Authored by mwolff on Apr 4 2018, 11:34 PM.

Details

Summary

This is a refinement of the previous patch, which isn't perfect yet:
Assume you have a project at /A/B/C. Now, you have
these two files in there:

/A/B/C/D/file
/A/B/C/C/E/file

Note also how quickopen trims the shared prefix path when it displays
the results:

D/file
C/E/file

When you search for C/file, both files used to get the same quality,
even though the former one matches only in the shared prefix path
of the project.

This patch adds a penalty when the match happens in the shared
prefix. Thus, when you search for C/file you'd now get the second
path preferred. This is imo much more desirable.

The benchmark timings are still pretty much the same.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mwolff created this revision.Apr 4 2018, 11:34 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptApr 4 2018, 11:34 PM
mwolff requested review of this revision.Apr 4 2018, 11:34 PM
mwolff updated this revision to Diff 31469.Apr 6 2018, 10:46 AM

fix a corner case where we miscalculated the inPrefixPath

segmentMatchDistance was off-by-one since pathIndex is decremented
after the last match. Account for that to ensure that a path that's
directly in the project root is not considered in the prefix path.

LGTM

kdevplatform/language/interfaces/abbreviations.cpp
226 ↗(On Diff #31469)

Indentation

mwolff added inline comments.Apr 9 2018, 12:02 PM
kdevplatform/language/interfaces/abbreviations.cpp
226 ↗(On Diff #31469)

yeah looks like I fubared the indentation since this file is a special snowflake and uses indent-width 2 but I copy'n'pasted indent-width 4 code from elsewhere when I moved this code here :(

This revision was not accepted when it landed; it landed in state Needs Review.Apr 9 2018, 6:31 PM
This revision was automatically updated to reflect the committed changes.