LSP: fix codeassists running check

Since MessageId is always valid (needs to be fixed separately)
use an optional to store whether we have a request running.

Change-Id: I7a1f136a09d776b33509bc914247d11076abeaa5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-05-14 08:15:39 +02:00
parent 32d29f5a11
commit f3407bb0ca
3 changed files with 18 additions and 16 deletions

View File

@@ -285,7 +285,7 @@ private:
QPointer<QTextDocument> m_document;
QPointer<Client> m_client;
MessageId m_currentRequest;
Utils::optional<MessageId> m_currentRequest;
int m_pos = -1;
};
@@ -353,15 +353,15 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn
bool LanguageClientCompletionAssistProcessor::running()
{
return m_currentRequest.isValid();
return m_currentRequest.has_value();
}
void LanguageClientCompletionAssistProcessor::cancel()
{
if (running()) {
m_client->cancelRequest(m_currentRequest);
m_client->cancelRequest(m_currentRequest.value());
m_client->removeAssistProcessor(this);
m_currentRequest = MessageId();
m_currentRequest.reset();
}
}
@@ -370,7 +370,7 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
{
// We must report back to the code assistant under all circumstances
qCDebug(LOGLSPCOMPLETION) << QTime::currentTime() << " : got completions";
m_currentRequest = MessageId();
m_currentRequest.reset();
QTC_ASSERT(m_client, setAsyncProposalAvailable(nullptr); return);
if (auto error = response.error())
m_client->log(error.value());