LanguageClient: avoid recursive postponed document update

Change-Id: Ibaf8831977e254c7dad10617754e763114993aee
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-09-10 09:12:20 +02:00
parent 3b23cab385
commit 3a51cdf2ba

View File

@@ -1139,6 +1139,15 @@ void Client::sendPostponedDocumentUpdates()
return;
TextEditor::TextEditorWidget *currentWidget
= TextEditor::TextEditorWidget::currentTextEditorWidget();
struct DocumentUpdate
{
TextEditor::TextDocument *document;
DidChangeTextDocumentNotification notification;
};
QList<DocumentUpdate> updates;
const QList<TextEditor::TextDocument *> documents = m_documentsToUpdate.keys();
for (auto document : documents) {
const auto uri = DocumentUri::fromFilePath(document->filePath());
@@ -1148,10 +1157,15 @@ void Client::sendPostponedDocumentUpdates()
DidChangeTextDocumentParams params;
params.setTextDocument(docId);
params.setContentChanges(m_documentsToUpdate.take(document));
sendContent(DidChangeTextDocumentNotification(params));
emit documentUpdated(document);
if (currentWidget && currentWidget->textDocument() == document)
updates.append({document, DidChangeTextDocumentNotification(params)});
}
for (const DocumentUpdate &update : qAsConst(updates)) {
sendContent(update.notification);
emit documentUpdated(update.document);
if (currentWidget && currentWidget->textDocument() == update.document)
cursorPositionChanged(currentWidget);
}
}