TextEditor: always return a valid assist interface

It is required for updating currently visible proposals. Also guard
against potential null assist interfaces.

Amends 0bd6d7a69f

Fixes: QTCREATORBUG-29096
Change-Id: Ic34d70561b471e7e529f2fb7c239b49712aca502
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2023-04-28 14:04:50 +02:00
parent 8aecf0d749
commit ba5e09f03f
4 changed files with 16 additions and 18 deletions

View File

@@ -175,8 +175,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
std::unique_ptr<AssistInterface> assistInterface =
m_editorWidget->createAssistInterface(kind, reason);
if (!assistInterface)
return;
QTC_ASSERT(assistInterface, return);
// We got an assist provider and interface so no need to reset the current context anymore
earlyReturnContextClear.reset({});
@@ -395,8 +394,10 @@ void CodeAssistantPrivate::notifyChange()
if (m_editorWidget->position() < m_proposalWidget->basePosition()) {
destroyContext();
} else {
m_proposalWidget->updateProposal(
m_editorWidget->createAssistInterface(m_assistKind, m_proposalWidget->reason()));
std::unique_ptr<AssistInterface> assistInterface
= m_editorWidget->createAssistInterface(m_assistKind, m_proposalWidget->reason());
QTC_ASSERT(assistInterface, destroyContext(); return);
m_proposalWidget->updateProposal(std::move(assistInterface));
if (!isDisplayingProposal())
requestActivationCharProposal();
}