diff --git a/src/completion/katecompletionmodel.h b/src/completion/katecompletionmodel.h --- a/src/completion/katecompletionmodel.h +++ b/src/completion/katecompletionmodel.h @@ -253,6 +253,11 @@ m_haveExactMatch = false; } + bool haveContainsMatch() const + { + return m_haveContainsMatch; + } + QString name() const { return m_nameColumn; @@ -271,6 +276,7 @@ // True when passes all active filters bool matchFilters; bool m_haveExactMatch; + bool m_haveContainsMatch; bool m_unimportant; QString completionSortingName() const; diff --git a/src/completion/katecompletionmodel.cpp b/src/completion/katecompletionmodel.cpp --- a/src/completion/katecompletionmodel.cpp +++ b/src/completion/katecompletionmodel.cpp @@ -1857,9 +1857,9 @@ bool doHide = false; CodeCompletionModel *hideModel = nullptr; - foreach (Group *group, m_rowTable) - foreach (const Item &item, group->filtered) - if (item.haveExactMatch()) { + for (const Group *group : qAsConst(m_rowTable)) { + for (const Item &item : qAsConst(group->filtered)) { + if (item.haveExactMatch() || item.haveContainsMatch()) { KTextEditor::CodeCompletionModelControllerInterface *iface3 = dynamic_cast(item.sourceRow().first); bool hide = false; if (!iface3) { @@ -1873,14 +1873,18 @@ hideModel = item.sourceRow().first; } } + } + } if (doHide) { // Check if all other visible items are from the same model - foreach (Group *group, m_rowTable) - foreach (const Item &item, group->filtered) + for (const Group *group : qAsConst(m_rowTable)) { + for (const Item &item : qAsConst(group->filtered)) { if (item.sourceRow().first != hideModel) { return false; } + } + } } return doHide; @@ -1997,6 +2001,7 @@ QString match = model->currentCompletion(m_sourceRow.first); m_haveExactMatch = false; + m_haveContainsMatch = false; // Hehe, everything matches nothing! (ie. everything matches a blank string) if (match.isEmpty()) { @@ -2014,6 +2019,7 @@ // Starting at 1 saves looking at the beginning of the word, that was already checked above. if (containsAtWordBeginning(m_nameColumn, match, model->matchCaseSensitivity())) { matchCompletion = ContainsMatch; + m_haveContainsMatch = true; } }