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;
|
IAssistProposalWidget *m_proposalWidget = nullptr;
|
||||||
QScopedPointer<IAssistProposal> m_proposal;
|
QScopedPointer<IAssistProposal> m_proposal;
|
||||||
bool m_receivedContentWhileWaiting = false;
|
bool m_receivedContentWhileWaiting = false;
|
||||||
|
bool m_proposalItemProcessed = false;
|
||||||
QTimer m_automaticProposalTimer;
|
QTimer m_automaticProposalTimer;
|
||||||
CompletionSettings m_settings;
|
CompletionSettings m_settings;
|
||||||
int m_abortedBasePosition = -1;
|
int m_abortedBasePosition = -1;
|
||||||
@@ -192,6 +193,13 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
|||||||
if (m_editorWidget->hasBlockSelection())
|
if (m_editorWidget->hasBlockSelection())
|
||||||
return; // TODO
|
return; // TODO
|
||||||
|
|
||||||
|
if (m_proposalItemProcessed
|
||||||
|
&& reason == IdleEditor
|
||||||
|
&& m_assistKind == TextEditor::Completion
|
||||||
|
&& !identifyActivationSequence()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
if (kind == Completion)
|
if (kind == Completion)
|
||||||
provider = m_editorWidget->textDocument()->completionAssistProvider();
|
provider = m_editorWidget->textDocument()->completionAssistProvider();
|
||||||
@@ -358,6 +366,15 @@ void CodeAssistantPrivate::processProposalItem(AssistProposalItemInterface *prop
|
|||||||
if (!proposalItem->isSnippet())
|
if (!proposalItem->isSnippet())
|
||||||
process();
|
process();
|
||||||
m_editorWidget->encourageApply();
|
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)
|
void CodeAssistantPrivate::handlePrefixExpansion(const QString &newPrefix)
|
||||||
|
Reference in New Issue
Block a user