diff --git a/src/libs/utils/camelhumpmatcher.cpp b/src/libs/utils/camelhumpmatcher.cpp index 51206262d44..b82cd2d8998 100644 --- a/src/libs/utils/camelhumpmatcher.cpp +++ b/src/libs/utils/camelhumpmatcher.cpp @@ -65,6 +65,7 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp( */ QString keyRegExp; + QString plainRegExp; bool first = true; const QChar asterisk = '*'; const QChar question = '?'; @@ -76,12 +77,17 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp( keyRegExp += "(?:"; for (const QChar &c : pattern) { if (!c.isLetter()) { - if (c == question) + if (c == question) { keyRegExp += '.'; - else if (c == asterisk) + plainRegExp += '.'; + } else if (c == asterisk) { keyRegExp += ".*"; - else - keyRegExp += '(' + QRegularExpression::escape(c) + ')'; + plainRegExp += ".*"; + } else { + const QString escaped = QRegularExpression::escape(c); + keyRegExp += '(' + escaped + ')'; + plainRegExp += escaped; + } } else if (caseSensitivity == CaseSensitivity::CaseInsensitive || (caseSensitivity == CaseSensitivity::FirstLetterCaseSensitive && !first)) { @@ -97,6 +103,7 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp( keyRegExp += '|' + upperSnakeWordContinuation + '(' + upper + ')'; } keyRegExp += ')'; + plainRegExp += '[' + upper + lower + ']'; } else { if (!first) { if (c.isUpper()) @@ -104,12 +111,14 @@ QRegularExpression CamelHumpMatcher::createCamelHumpRegExp( else keyRegExp += lowercaseWordContinuation; } - keyRegExp += QRegularExpression::escape(c); + const QString escaped = QRegularExpression::escape(c); + keyRegExp += escaped; + plainRegExp += escaped; } first = false; } - keyRegExp += ")|(" + QRegularExpression::escape(pattern) + ')'; + keyRegExp += ")|(" + plainRegExp + ')'; return QRegularExpression(keyRegExp); } diff --git a/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp b/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp index 0b5774ee63b..d9b54743411 100644 --- a/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp +++ b/tests/auto/utils/camelhumpmatcher/tst_camelhumpmatcher.cpp @@ -79,6 +79,8 @@ void tst_CamelHumpMatcher::camelHumpMatcher_data() 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; + QTest::newRow("case-insensitive") << "window" << "MAINWINDOW.cpp" << 4; + QTest::newRow("case-insensitive-2") << "wINDow" << "MainwiNdow.cpp" << 4; } typedef QVector MatchStart;