diff --git a/src/plugins/texteditor/codeassist/assistproposaliteminterface.h b/src/plugins/texteditor/codeassist/assistproposaliteminterface.h index 893dc4aa0d3..3124b46197c 100644 --- a/src/plugins/texteditor/codeassist/assistproposaliteminterface.h +++ b/src/plugins/texteditor/codeassist/assistproposaliteminterface.h @@ -46,8 +46,9 @@ public: { Full = 0, Exact = 1, - Lower = 2, - None = 3 + Prefix = 2, + Infix = 3, + None = 4 }; AssistProposalItemInterface() = default; diff --git a/src/plugins/texteditor/codeassist/genericproposalmodel.cpp b/src/plugins/texteditor/codeassist/genericproposalmodel.cpp index 29efd1799d2..19e1a0962b2 100644 --- a/src/plugins/texteditor/codeassist/genericproposalmodel.cpp +++ b/src/plugins/texteditor/codeassist/genericproposalmodel.cpp @@ -301,7 +301,10 @@ void GenericProposalModel::filter(const QString &prefix) const QString lowerPrefix = prefix.toLower(); for (const auto &item : qAsConst(m_originalItems)) { const QString &text = item->text(); - if (regExp.match(text).capturedStart() == 0) { + const QRegularExpressionMatch match = regExp.match(text); + const bool hasPrefixMatch = match.capturedStart() == 0; + const bool hasInfixMatch = prefix.size() >= 3 && match.hasMatch(); + if (hasPrefixMatch || hasInfixMatch) { m_currentItems.append(item); if (text.startsWith(prefix)) { // Direct match @@ -312,7 +315,9 @@ void GenericProposalModel::filter(const QString &prefix) } if (text.startsWith(lowerPrefix, Qt::CaseInsensitive)) - item->setPrefixMatch(AssistProposalItemInterface::PrefixMatch::Lower); + item->setPrefixMatch(AssistProposalItemInterface::PrefixMatch::Prefix); + else if (text.contains(lowerPrefix, Qt::CaseInsensitive)) + item->setPrefixMatch(AssistProposalItemInterface::PrefixMatch::Infix); } } }