Commit 9b9b5605 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

quickopen: strip common prefix when matching path

parent fd038bcc
...@@ -83,7 +83,7 @@ protected: ...@@ -83,7 +83,7 @@ protected:
// only match file path if filename got a match // only match file path if filename got a match
bool resp = false; bool resp = false;
if (resn || pathLike) { if (resn || pathLike) {
const QString &path = sm->idxToFilePath(sourceRow); const QStringView path = sm->idxToFilePath(sourceRow);
resp = filterByPath(path, scorep); resp = filterByPath(path, scorep);
} }
...@@ -114,7 +114,7 @@ public Q_SLOTS: ...@@ -114,7 +114,7 @@ public Q_SLOTS:
} }
private: private:
inline bool filterByPath(const QString &path, int &score) const inline bool filterByPath(const QStringView path, int &score) const
{ {
return kfts::fuzzy_match(pattern, path, score); return kfts::fuzzy_match(pattern, path, score);
} }
......
...@@ -62,9 +62,11 @@ public: ...@@ -62,9 +62,11 @@ public:
return m_modelEntries.at(row).fileName; return m_modelEntries.at(row).fileName;
} }
const QString &idxToFilePath(int row) const const QStringView idxToFilePath(int row) const
{ {
return m_modelEntries.at(row).filePath; const auto &path = m_modelEntries.at(row).filePath;
// handle exceptional non-saved file case
return path.startsWith(m_projectBase) ? QStringView(path).mid(m_projectBase.size()) : path;
} }
int idxScore(const QModelIndex &idx) const int idxScore(const QModelIndex &idx) const
......
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