LanguageClient: remove fragile flag from lsp proposals

Those proposals are not fragile anymore since they reuse the old
completion widget. This fixes vanishing of none idle editor completions
on backspace if there are less than 3 characters to complete.
Additionally this removes the double completion request if there are
more than 3 characters typed in.

Change-Id: Id47d341adf954dfaaaeb70c17f6774ba38cc8bdf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-07-08 13:07:48 +02:00
committed by Christian Stenger
parent 8953be1d3f
commit 13af74a4e8
2 changed files with 5 additions and 3 deletions

View File

@@ -447,7 +447,6 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
model);
proposal->m_document = m_document;
proposal->m_pos = m_pos;
proposal->setFragile(true);
proposal->setSupportsPrefix(false);
setAsyncProposalAvailable(proposal);
m_client->removeAssistProcessor(this);

View File

@@ -155,7 +155,8 @@ void CodeAssistantPrivate::invoke(AssistKind kind, IAssistProvider *provider)
stopAutomaticProposalTimer();
if (isDisplayingProposal() && m_assistKind == kind && !m_proposal->isFragile()) {
if (isDisplayingProposal() && m_assistKind == kind && !m_proposal->isFragile()
&& m_proposal->supportsPrefix()) {
m_proposalWidget->setReason(ExplicitlyInvoked);
m_proposalWidget->updateProposal(m_editorWidget->textAt(
m_proposal->basePosition(),
@@ -324,8 +325,10 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
// TODO: The proposal should own the model until someone takes it explicitly away.
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
if (isDisplayingProposal() && !m_proposal->isFragile())
if (isDisplayingProposal() && !m_proposal->isFragile()
&& !m_proposalWidget->supportsModelUpdate(proposalCandidate->id())) {
return;
}
int basePosition = proposalCandidate->basePosition();
if (m_editorWidget->position() < basePosition) {