forked from qt-creator/qt-creator
TextEditor: Allow incremental proposals
... and make use of them with clangd. This way, users can get immediate feedback when a new proposal entry has been found, rather than having to wait until all of them have been collected. Change-Id: I2adfe0153aa7a058f28eb3bd65c71dd30ea018e0 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -252,11 +252,14 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
break;
|
||||
}
|
||||
case IAssistProvider::Asynchronous: {
|
||||
processor->setAsyncCompletionAvailableHandler([this, reason, processor](IAssistProposal *newProposal) {
|
||||
// do not delete this processor directly since this function is called from within the processor
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [processor]() {
|
||||
delete processor;
|
||||
}, Qt::QueuedConnection);
|
||||
processor->setAsyncCompletionAvailableHandler([this, reason, processor](
|
||||
IAssistProposal *newProposal) {
|
||||
if (!processor->running()) {
|
||||
// do not delete this processor directly since this function is called from within the processor
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [processor]() {
|
||||
delete processor;
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
if (processor != m_asyncProcessor)
|
||||
return;
|
||||
invalidateCurrentRequestData();
|
||||
@@ -266,7 +269,10 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
requestProposal(reason, m_assistKind, m_requestProvider);
|
||||
} else {
|
||||
displayProposal(newProposal, reason);
|
||||
emit q->finished();
|
||||
if (processor && processor->running())
|
||||
m_asyncProcessor = processor;
|
||||
else
|
||||
emit q->finished();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -565,6 +571,9 @@ bool CodeAssistantPrivate::eventFilter(QObject *o, QEvent *e)
|
||||
destroyContext();
|
||||
else if (!keyText.isEmpty() && !m_receivedContentWhileWaiting)
|
||||
m_receivedContentWhileWaiting = true;
|
||||
} else if (type == QEvent::KeyRelease
|
||||
&& static_cast<QKeyEvent *>(e)->key() == Qt::Key_Escape) {
|
||||
destroyContext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user