forked from qt-creator/qt-creator
LanguageClient: avoid recursive postponed document update
Change-Id: Ibaf8831977e254c7dad10617754e763114993aee Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1139,6 +1139,15 @@ void Client::sendPostponedDocumentUpdates()
|
|||||||
return;
|
return;
|
||||||
TextEditor::TextEditorWidget *currentWidget
|
TextEditor::TextEditorWidget *currentWidget
|
||||||
= TextEditor::TextEditorWidget::currentTextEditorWidget();
|
= TextEditor::TextEditorWidget::currentTextEditorWidget();
|
||||||
|
|
||||||
|
struct DocumentUpdate
|
||||||
|
{
|
||||||
|
TextEditor::TextDocument *document;
|
||||||
|
DidChangeTextDocumentNotification notification;
|
||||||
|
};
|
||||||
|
|
||||||
|
QList<DocumentUpdate> updates;
|
||||||
|
|
||||||
const QList<TextEditor::TextDocument *> documents = m_documentsToUpdate.keys();
|
const QList<TextEditor::TextDocument *> documents = m_documentsToUpdate.keys();
|
||||||
for (auto document : documents) {
|
for (auto document : documents) {
|
||||||
const auto uri = DocumentUri::fromFilePath(document->filePath());
|
const auto uri = DocumentUri::fromFilePath(document->filePath());
|
||||||
@@ -1148,10 +1157,15 @@ void Client::sendPostponedDocumentUpdates()
|
|||||||
DidChangeTextDocumentParams params;
|
DidChangeTextDocumentParams params;
|
||||||
params.setTextDocument(docId);
|
params.setTextDocument(docId);
|
||||||
params.setContentChanges(m_documentsToUpdate.take(document));
|
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);
|
cursorPositionChanged(currentWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user