forked from qt-creator/qt-creator
Clang: Add sorting by priority
The priority is adjusted too provide a better completion list. Change-Id: I1ebed1996f660046843e0c5249a91e8c2b1eeb88 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -32,6 +32,10 @@
|
||||
|
||||
#include "clangassistproposalmodel.h"
|
||||
|
||||
#include <texteditor/codeassist/assistproposalitem.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
@@ -56,6 +60,19 @@ bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClangAssistProposalModel::sort(const QString &/*prefix*/)
|
||||
{
|
||||
using TextEditor::AssistProposalItem;
|
||||
|
||||
auto currentItemsCompare = [](AssistProposalItem *first, AssistProposalItem *second) {
|
||||
return (first->order() > 0
|
||||
&& (first->order() < second->order()
|
||||
|| (first->order() == second->order() && first->text() < second->text())));
|
||||
};
|
||||
|
||||
std::sort(m_currentItems.begin(), m_currentItems.end(), currentItemsCompare);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
|
||||
Reference in New Issue
Block a user