forked from qt-creator/qt-creator
TextEditor: Fix requesting more proposals than needed
Since
commit d61d29cf16
Introduce a basic client for the language server protocol
extra proprosals were requested in the fragile case on a change
notification, e.g. for function signature completion. Restrict this to
the language client proposal, as it was actually intended.
The language client does not support prefixes, so introduce this concept
for deciding whether to request new proposals or not.
Done-with: David Schulz
Change-Id: Ibc1ad82dbeeea93b85f279c59b8c7289fe6ec726
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -372,6 +372,7 @@ void LanguageClientCompletionAssistProcessor::handleCompletionResponse(
|
|||||||
proposal->m_document = m_document;
|
proposal->m_document = m_document;
|
||||||
proposal->m_pos = m_pos;
|
proposal->m_pos = m_pos;
|
||||||
proposal->setFragile(true);
|
proposal->setFragile(true);
|
||||||
|
proposal->setSupportsPrefix(false);
|
||||||
setAsyncProposalAvailable(proposal);
|
setAsyncProposalAvailable(proposal);
|
||||||
qCDebug(LOGLSPCOMPLETION) << QTime::currentTime() << " : "
|
qCDebug(LOGLSPCOMPLETION) << QTime::currentTime() << " : "
|
||||||
<< items.count() << " completions handled";
|
<< items.count() << " completions handled";
|
||||||
|
@@ -440,7 +440,7 @@ void CodeAssistantPrivate::notifyChange()
|
|||||||
QTC_ASSERT(m_proposal, return);
|
QTC_ASSERT(m_proposal, return);
|
||||||
if (m_editorWidget->position() < m_proposal->basePosition()) {
|
if (m_editorWidget->position() < m_proposal->basePosition()) {
|
||||||
destroyContext();
|
destroyContext();
|
||||||
} else if (!m_proposal->isFragile()) {
|
} else if (m_proposal->supportsPrefix()) {
|
||||||
m_proposalWidget->updateProposal(
|
m_proposalWidget->updateProposal(
|
||||||
m_editorWidget->textAt(m_proposal->basePosition(),
|
m_editorWidget->textAt(m_proposal->basePosition(),
|
||||||
m_editorWidget->position() - m_proposal->basePosition()));
|
m_editorWidget->position() - m_proposal->basePosition()));
|
||||||
|
@@ -90,6 +90,11 @@ bool IAssistProposal::isFragile() const
|
|||||||
return m_isFragile;
|
return m_isFragile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IAssistProposal::supportsPrefix() const
|
||||||
|
{
|
||||||
|
return m_supportsPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool TextEditor::IAssistProposal::isCorrective() const
|
\fn bool TextEditor::IAssistProposal::isCorrective() const
|
||||||
|
|
||||||
@@ -120,6 +125,11 @@ void IAssistProposal::setFragile(bool fragile)
|
|||||||
m_isFragile = fragile;
|
m_isFragile = fragile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IAssistProposal::setSupportsPrefix(bool supportsPrefix)
|
||||||
|
{
|
||||||
|
m_supportsPrefix = supportsPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn IAssistModel *TextEditor::IAssistProposal::model() const
|
\fn IAssistModel *TextEditor::IAssistProposal::model() const
|
||||||
|
|
||||||
|
@@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
int basePosition() const;
|
int basePosition() const;
|
||||||
bool isFragile() const;
|
bool isFragile() const;
|
||||||
|
bool supportsPrefix() const;
|
||||||
virtual bool hasItemsToPropose(const QString &, AssistReason) const { return true; }
|
virtual bool hasItemsToPropose(const QString &, AssistReason) const { return true; }
|
||||||
virtual bool isCorrective(TextEditorWidget *editorWidget) const;
|
virtual bool isCorrective(TextEditorWidget *editorWidget) const;
|
||||||
virtual void makeCorrection(TextEditorWidget *editorWidget);
|
virtual void makeCorrection(TextEditorWidget *editorWidget);
|
||||||
@@ -50,9 +51,11 @@ public:
|
|||||||
virtual IAssistProposalWidget *createWidget() const = 0;
|
virtual IAssistProposalWidget *createWidget() const = 0;
|
||||||
|
|
||||||
void setFragile(bool fragile);
|
void setFragile(bool fragile);
|
||||||
|
void setSupportsPrefix(bool supportsPrefix);
|
||||||
protected:
|
protected:
|
||||||
int m_basePosition;
|
int m_basePosition;
|
||||||
bool m_isFragile = false;
|
bool m_isFragile = false;
|
||||||
|
bool m_supportsPrefix = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // TextEditor
|
} // TextEditor
|
||||||
|
Reference in New Issue
Block a user