Editor: Fix dangling completion widgets

Set the correct assist reason when rerequesting a code assist to be able
to detect perfect matches. Also destroy the code assist context when the
processor is not running and has not returned a proposal after perform.

Change-Id: Ieb04203269076655ac3d7ffc54ea8a1d055194a4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2022-06-23 14:35:52 +02:00
parent 67a08683d1
commit c3cb262154
2 changed files with 7 additions and 1 deletions

View File

@@ -284,6 +284,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
displayProposal(newProposal, reason);
delete processor;
} else if (!processor->running()) {
destroyContext();
delete processor;
} else { // ...async request was triggered
if (IAssistProposal *newProposal = processor->immediateProposal(assistInterface))
@@ -354,6 +355,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
clearAbortedPosition();
m_proposal.reset(proposalCandidate.take());
m_proposal->setReason(reason);
if (m_proposal->isCorrective(m_editorWidget))
m_proposal->makeCorrection(m_editorWidget);
@@ -485,7 +487,7 @@ void CodeAssistantPrivate::notifyChange()
if (!isDisplayingProposal())
requestActivationCharProposal();
} else {
requestProposal(ExplicitlyInvoked, m_assistKind, m_requestProvider);
requestProposal(m_proposal->reason(), m_assistKind, m_requestProvider);
}
}
}