Commit f7924757 authored by Andre Hartmann's avatar Andre Hartmann Committed by André Hartmann

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's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent b35fe9bf
......@@ -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)
......
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