Commit 01abd0d5 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Only match filename by default in quickopen

Reasoning:
Firstly, I think it was just a very poor decision to match both if
filename matched. When filename got matched, it is unnecessary to match
the path and can lead to worse results if we do it. Consider files:

path/to/FileView.cpp
files/views/to/FileViewModel.cpp
...

First file match will happen, which most likely gives us the first file
for a pattern "fv". But then path matching which can ruin this result
and give some other irrelevant match a higher score leading to worse
results in quickopen

In kate, we work with files (from a user POV). User mostly sees filename
and will most likely be matching against file names, and rarely against
paths.

The other benefit that this gives is HUGELY better performance. This is
atleast 2x faster, so with large repos quick open will be much nicer to
use.

if one really wants to match a path, then specifying a pattern like:

src/fv

will do it. This is already supported, so it isn't something new.
parent 5345f483
......@@ -79,7 +79,7 @@ protected:
bool res = filterByName(QStringView(name.data(), name.size()), QStringView(pattern.data(), pattern.size()), score);
// only match file path if filename got a match
if (res || pathLike) {
if (matchPath) {
int scorep = 0;
QStringView path{sm->idxToFilePath(sourceRow)};
bool resp = filterByPath(path, QStringView(pattern.data(), pattern.size()), scorep);
......@@ -103,7 +103,7 @@ public Q_SLOTS:
beginResetModel();
pattern = splitted;
pathLike = pattern.contains(QLatin1Char('/'));
matchPath = pattern.contains(QLatin1Char('/'));
endResetModel();
return true;
......@@ -122,7 +122,7 @@ private:
private:
QString pattern;
bool pathLike = false;
bool matchPath = false;
};
class QuickOpenStyleDelegate : public QStyledItemDelegate
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment