forked from qt-creator/qt-creator
LanguageClient: fix showing obsolete proposals
When receiving a null proposal and the processor is not running after updating a proposal we need to make sure the previous visible proposal widget gets closed. Change-Id: Icb0a7293698e603df3ba8cab34a08c10fe6784da Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -287,8 +287,13 @@ public:
|
|||||||
|
|
||||||
void setProposal(IAssistProposal *proposal, const QString &prefix)
|
void setProposal(IAssistProposal *proposal, const QString &prefix)
|
||||||
{
|
{
|
||||||
if (!proposal)
|
if (!proposal) {
|
||||||
|
// Close the proposal if we have no running processor otherwise ignore the empty
|
||||||
|
// proposal and wait for the processor to finish
|
||||||
|
if (!m_processor || !m_processor->running())
|
||||||
|
closeProposal();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (proposal->id() != TextEditor::Constants::GENERIC_PROPOSAL_ID) {
|
if (proposal->id() != TextEditor::Constants::GENERIC_PROPOSAL_ID) {
|
||||||
// We received something else than a generic proposal so we cannot update the model
|
// We received something else than a generic proposal so we cannot update the model
|
||||||
closeProposal();
|
closeProposal();
|
||||||
@@ -305,13 +310,14 @@ public:
|
|||||||
GenericProposalWidget::updateProposal(std::move(interface));
|
GenericProposalWidget::updateProposal(std::move(interface));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto processor = m_provider->createProcessor(interface.get());
|
m_processor = m_provider->createProcessor(interface.get());
|
||||||
QTC_ASSERT(processor, return);
|
QTC_ASSERT(m_processor, return);
|
||||||
|
|
||||||
const QString prefix = interface->textAt(m_basePosition,
|
const QString prefix = interface->textAt(m_basePosition,
|
||||||
interface->position() - m_basePosition);
|
interface->position() - m_basePosition);
|
||||||
|
|
||||||
processor->setAsyncCompletionAvailableHandler([this, processor, prefix](IAssistProposal *proposal) {
|
m_processor->setAsyncCompletionAvailableHandler([this, processor = m_processor, prefix](
|
||||||
|
IAssistProposal *proposal) {
|
||||||
QTC_ASSERT(processor == m_processor, return);
|
QTC_ASSERT(processor == m_processor, return);
|
||||||
if (!processor->running()) {
|
if (!processor->running()) {
|
||||||
// do not delete this processor directly since this function is called from within the processor
|
// do not delete this processor directly since this function is called from within the processor
|
||||||
@@ -324,11 +330,11 @@ public:
|
|||||||
setProposal(proposal, prefix);
|
setProposal(proposal, prefix);
|
||||||
});
|
});
|
||||||
|
|
||||||
setProposal(processor->start(std::move(interface)), prefix);
|
setProposal(m_processor->start(std::move(interface)), prefix);
|
||||||
if (processor->running())
|
if (!m_processor->running()) {
|
||||||
m_processor = processor;
|
delete m_processor;
|
||||||
else
|
m_processor = nullptr;
|
||||||
delete processor;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user