forked from qt-creator/qt-creator
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:
@@ -284,6 +284,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
|||||||
displayProposal(newProposal, reason);
|
displayProposal(newProposal, reason);
|
||||||
delete processor;
|
delete processor;
|
||||||
} else if (!processor->running()) {
|
} else if (!processor->running()) {
|
||||||
|
destroyContext();
|
||||||
delete processor;
|
delete processor;
|
||||||
} else { // ...async request was triggered
|
} else { // ...async request was triggered
|
||||||
if (IAssistProposal *newProposal = processor->immediateProposal(assistInterface))
|
if (IAssistProposal *newProposal = processor->immediateProposal(assistInterface))
|
||||||
@@ -354,6 +355,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
|
|||||||
|
|
||||||
clearAbortedPosition();
|
clearAbortedPosition();
|
||||||
m_proposal.reset(proposalCandidate.take());
|
m_proposal.reset(proposalCandidate.take());
|
||||||
|
m_proposal->setReason(reason);
|
||||||
|
|
||||||
if (m_proposal->isCorrective(m_editorWidget))
|
if (m_proposal->isCorrective(m_editorWidget))
|
||||||
m_proposal->makeCorrection(m_editorWidget);
|
m_proposal->makeCorrection(m_editorWidget);
|
||||||
@@ -485,7 +487,7 @@ void CodeAssistantPrivate::notifyChange()
|
|||||||
if (!isDisplayingProposal())
|
if (!isDisplayingProposal())
|
||||||
requestActivationCharProposal();
|
requestActivationCharProposal();
|
||||||
} else {
|
} else {
|
||||||
requestProposal(ExplicitlyInvoked, m_assistKind, m_requestProvider);
|
requestProposal(m_proposal->reason(), m_assistKind, m_requestProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,11 +57,15 @@ public:
|
|||||||
|
|
||||||
Utils::Id id() const { return m_id; }
|
Utils::Id id() const { return m_id; }
|
||||||
|
|
||||||
|
AssistReason reason() const { return m_reason; }
|
||||||
|
void setReason(const AssistReason &reason) { m_reason = reason; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Utils::Id m_id;
|
Utils::Id m_id;
|
||||||
int m_basePosition;
|
int m_basePosition;
|
||||||
bool m_isFragile = false;
|
bool m_isFragile = false;
|
||||||
bool m_supportsPrefix = true;
|
bool m_supportsPrefix = true;
|
||||||
|
AssistReason m_reason;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // TextEditor
|
} // TextEditor
|
||||||
|
Reference in New Issue
Block a user