forked from qt-creator/qt-creator
FuzzyMatcher: Match mixed uppercase words and humps
"htvideoele" did not match "HTMLVideoElement" before. This can easily be achieved by modifying the uppercase snake matcher and thus making the underscore between the letters optional. Fixes: QTCREATORBUG-19838 Change-Id: I821a68b20d40fb0843c12f43f47133833c75cb9b Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
3213e12ce7
commit
5dd4bb62b1
@@ -72,7 +72,7 @@ QRegularExpression FuzzyMatcher::createRegExp(
|
||||
const QLatin1String lowercaseWordFirst("(?<=\\b|[A-Z0-9_])");
|
||||
const QLatin1String uppercaseWordContinuation("[a-z0-9_]*");
|
||||
const QLatin1String lowercaseWordContinuation("(?:[a-zA-Z0-9]*_)?");
|
||||
const QLatin1String upperSnakeWordContinuation("[A-Z0-9]*_");
|
||||
const QLatin1String upperSnakeWordContinuation("[A-Z0-9]*_?");
|
||||
keyRegExp += "(?:";
|
||||
for (const QChar &c : pattern) {
|
||||
if (!c.isLetterOrNumber()) {
|
||||
|
@@ -86,6 +86,7 @@ void tst_FuzzyMatcher::fuzzyMatcher_data()
|
||||
QTest::newRow("middle-no-hump") << "window" << "mainwindow.cpp" << 4;
|
||||
QTest::newRow("case-insensitive") << "window" << "MAINWINDOW.cpp" << 4;
|
||||
QTest::newRow("case-insensitive-2") << "wINDow" << "MainwiNdow.cpp" << 4;
|
||||
QTest::newRow("uppercase-word-and-humps") << "htvideoele" << "HTMLVideoElement" << 0;
|
||||
}
|
||||
|
||||
typedef QVector<QPair<int, int>> Matches;
|
||||
@@ -159,6 +160,8 @@ void tst_FuzzyMatcher::highlighting_data()
|
||||
<< Matches{{4, 2}, {7, 1}};
|
||||
QTest::newRow("middle-no-hump") << "window" << "mainwindow.cpp"
|
||||
<< Matches{{4, 6}};
|
||||
QTest::newRow("uppercase-word-and-humps") << "htvideoele" << "HTMLVideoElement"
|
||||
<< Matches{{0, 2}, {4, 8}};
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_FuzzyMatcher)
|
||||
|
Reference in New Issue
Block a user