forked from qt-creator/qt-creator
Fix matching of partial paths on Windows
The paths against which the match is done always have forward slashes (i.e. uniform separator on all platforms). However the needle passed in has backward slashes on Windows usually, since this is how the paths are shown to the users and what is natural on windows too. Even explicitly using forward slash in the needle does not work here, since then the needle is not detected as containing a path (hasPathSeparator is false since it uses the native separator). Since it seems that the code internally favors the 'uniform' separators using slashes, simply convert the needle from native to uniform separators and use the forward slash to decide whether the needle has a path in it. Side effect of this is that it is now possible to use forward slashes when typing into the locator UI on windows. The opposite does not work on Unix though. That could be considered a feature though for cross-platform developers. Task-number: QTCREATORBUG-12007 Change-Id: I5064bd9c60936466dd04671ef42a578df26ea7b8 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
0f05aa42da
commit
cf6e4b8dcb
@@ -49,14 +49,14 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Core::Loca
|
|||||||
updateFiles();
|
updateFiles();
|
||||||
QList<LocatorFilterEntry> betterEntries;
|
QList<LocatorFilterEntry> betterEntries;
|
||||||
QList<LocatorFilterEntry> goodEntries;
|
QList<LocatorFilterEntry> goodEntries;
|
||||||
QString needle = trimWildcards(origEntry);
|
QString needle = trimWildcards(QDir::fromNativeSeparators(origEntry));
|
||||||
const QString lineNoSuffix = EditorManager::splitLineNumber(&needle);
|
const QString lineNoSuffix = EditorManager::splitLineNumber(&needle);
|
||||||
QStringMatcher matcher(needle, Qt::CaseInsensitive);
|
QStringMatcher matcher(needle, Qt::CaseInsensitive);
|
||||||
const QChar asterisk = QLatin1Char('*');
|
const QChar asterisk = QLatin1Char('*');
|
||||||
QRegExp regexp(asterisk + needle+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
|
QRegExp regexp(asterisk + needle+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
return betterEntries;
|
return betterEntries;
|
||||||
const QChar pathSeparator = QDir::separator();
|
const QChar pathSeparator(QLatin1Char('/'));
|
||||||
const bool hasPathSeparator = needle.contains(pathSeparator);
|
const bool hasPathSeparator = needle.contains(pathSeparator);
|
||||||
const bool hasWildcard = needle.contains(asterisk) || needle.contains(QLatin1Char('?'));
|
const bool hasWildcard = needle.contains(asterisk) || needle.contains(QLatin1Char('?'));
|
||||||
QStringList searchListPaths;
|
QStringList searchListPaths;
|
||||||
|
Reference in New Issue
Block a user