forked from qt-creator/qt-creator
CamelHumpMatcher: Fix matching word continuations without hump
Let the search string "window" also find "mainwindow.cpp", not just "MainWindow.cpp" Task-number: QTCREATORBUG-18957 Change-Id: Iace3111fb3ce319d916362c1f8d396844a3bc47a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
b35fe9bf53
commit
f792475739
@@ -73,6 +73,7 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp(
|
||||
const QLatin1String uppercaseWordContinuation("[a-z0-9_]*");
|
||||
const QLatin1String lowercaseWordContinuation("(?:[a-zA-Z0-9]*_)?");
|
||||
const QLatin1String upperSnakeWordContinuation("[A-Z0-9]*_");
|
||||
keyRegExp += "(?:";
|
||||
for (const QChar &c : pattern) {
|
||||
if (!c.isLetter()) {
|
||||
if (c == question)
|
||||
@@ -108,6 +109,8 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp(
|
||||
|
||||
first = false;
|
||||
}
|
||||
keyRegExp += ")|(" + QRegularExpression::escape(pattern) + ')';
|
||||
|
||||
return QRegularExpression(keyRegExp);
|
||||
}
|
||||
|
||||
|
@@ -77,6 +77,7 @@ void tst_CamelHumpMatcher::camelHumpMatcher_data()
|
||||
QTest::newRow("middle-after-underscore") << "CH" << "long_camel_hump" << 5;
|
||||
QTest::newRow("middle-after-underscore-uppercase") << "CH" << "LONG_CAMEL_HUMP" << 5;
|
||||
QTest::newRow("middle-continued") << "cahu" << "LongCamelHump" << 4;
|
||||
QTest::newRow("middle-no-hump") << "window" << "mainwindow.cpp" << 4;
|
||||
}
|
||||
|
||||
typedef QVector<int> MatchStart;
|
||||
@@ -136,6 +137,8 @@ void tst_CamelHumpMatcher::highlighting_data()
|
||||
<< MatchStart{4, 13} << MatchLength{2, 2};
|
||||
QTest::newRow("wildcard-question") << "Lo?g" << "VeryLongCamelHump"
|
||||
<< MatchStart{4, 7} << MatchLength{2, 1};
|
||||
QTest::newRow("middle-no-hump") << "window" << "mainwindow.cpp"
|
||||
<< MatchStart{4} << MatchLength{6};
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_CamelHumpMatcher)
|
||||
|
Reference in New Issue
Block a user