forked from qt-creator/qt-creator
CodeAssist: Avoid pointless completion request after accepting item
Previously, accepting an item from the completion pop-up triggered another completion request, but the result of that request was never displayed since the inserted text was a perfect match. Now, trigger another completion request only if the inserted text matches the activation characters. Change-Id: Ic8ed4139efb10aadc8d41105634fcc856e0a15be Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -104,6 +104,7 @@ private:
|
||||
IAssistProposalWidget *m_proposalWidget = nullptr;
|
||||
QScopedPointer<IAssistProposal> m_proposal;
|
||||
bool m_receivedContentWhileWaiting = false;
|
||||
bool m_proposalItemProcessed = false;
|
||||
QTimer m_automaticProposalTimer;
|
||||
CompletionSettings m_settings;
|
||||
int m_abortedBasePosition = -1;
|
||||
@@ -192,6 +193,13 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
if (m_editorWidget->hasBlockSelection())
|
||||
return; // TODO
|
||||
|
||||
if (m_proposalItemProcessed
|
||||
&& reason == IdleEditor
|
||||
&& m_assistKind == TextEditor::Completion
|
||||
&& !identifyActivationSequence()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!provider) {
|
||||
if (kind == Completion)
|
||||
provider = m_editorWidget->textDocument()->completionAssistProvider();
|
||||
@@ -358,6 +366,15 @@ void CodeAssistantPrivate::processProposalItem(AssistProposalItemInterface *prop
|
||||
if (!proposalItem->isSnippet())
|
||||
process();
|
||||
m_editorWidget->encourageApply();
|
||||
m_proposalItemProcessed = true;
|
||||
|
||||
auto connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = connect(m_editorWidget->textDocument(),
|
||||
&Core::IDocument::contentsChanged,
|
||||
this, [this, connection] {
|
||||
m_proposalItemProcessed = false;
|
||||
disconnect(*connection);
|
||||
});
|
||||
}
|
||||
|
||||
void CodeAssistantPrivate::handlePrefixExpansion(const QString &newPrefix)
|
||||
|
Reference in New Issue
Block a user