diff --git a/src/libs/utils/camelhumpmatcher.cpp b/src/libs/utils/camelhumpmatcher.cpp index 0661499c7a3..cb99cff1372 100644 --- a/src/libs/utils/camelhumpmatcher.cpp +++ b/src/libs/utils/camelhumpmatcher.cpp @@ -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); } diff --git a/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp b/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp index 3777c7b755f..6884ee8d7b8 100644 --- a/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp +++ b/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp @@ -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 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)