Commit e57b6ea8 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

FileFilter: make matching child files/dirs more precise

- When we match child files/dirs of the current dir, either the item name
is the "filename", or if it's a child-dir/somefile, then filename starts
with "child-dir + '/'".

To test create a file foo and a dir bar with a bar-file inside it then:
  - `ls`, foo and bar should be underlined
  - `ls bar/*`, bar/bar-file should be underlined
  - type bar..., before it would be underlined, after it won't be

- Capture QString by reference in lambda.
parent ac0b5ef4
......@@ -104,13 +104,12 @@ QSharedPointer<HotSpot> FileFilter::newHotSpot(int startLine, int startColumn, i
const bool absolute = filename.startsWith(QLatin1Char('/'));
if (!absolute) {
// Return nullptr if it's not:
// <current dir>/filename
// <current dir>/childDir/filename
auto match = std::find_if(_currentDirContents.cbegin(), _currentDirContents.cend(),
[filename](const QString &s) { return filename.startsWith(s); });
[&filename](const QString &s) {
return filename == s || // It's a direct child file or dir
filename.startsWith(s + QLatin1Char{'/'}); // It's inside a child dir
});
// Create a hotspot if the match starts with '/', which denotes an absolute path
if (match == _currentDirContents.cend()) {
return nullptr;
}
......
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