Client: rerequest document highlight if server is unreachable

Makes sure the highlight is properly updated and prevents assert in
Client::sendMessage.

Change-Id: Ie7ad54c34272867e17f6e20654f27e2fd8711fdc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-08-22 09:38:09 +02:00
parent 09f0ddb50c
commit 60f5275edf

View File

@@ -774,9 +774,13 @@ void ClientPrivate::requestDocumentHighlights(TextEditor::TextEditorWidget *widg
delete m_documentHighlightsTimer.take(widget); delete m_documentHighlightsTimer.take(widget);
}); });
connect(timer, &QTimer::timeout, this, [this, widget, connection]() { connect(timer, &QTimer::timeout, this, [this, widget, connection]() {
disconnect(connection); if (q->reachable()) {
requestDocumentHighlightsNow(widget); disconnect(connection);
m_documentHighlightsTimer.take(widget)->deleteLater(); requestDocumentHighlightsNow(widget);
m_documentHighlightsTimer.take(widget)->deleteLater();
} else {
m_documentHighlightsTimer[widget]->start(250);
}
}); });
} }
timer->start(250); timer->start(250);
@@ -784,6 +788,7 @@ void ClientPrivate::requestDocumentHighlights(TextEditor::TextEditorWidget *widg
void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *widget) void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *widget)
{ {
QTC_ASSERT(q->reachable(), return);
const auto uri = DocumentUri::fromFilePath(widget->textDocument()->filePath()); const auto uri = DocumentUri::fromFilePath(widget->textDocument()->filePath());
if (m_dynamicCapabilities.isRegistered(DocumentHighlightsRequest::methodName).value_or(false)) { if (m_dynamicCapabilities.isRegistered(DocumentHighlightsRequest::methodName).value_or(false)) {
TextDocumentRegistrationOptions option( TextDocumentRegistrationOptions option(