LanguageClient: connect the opened editor to LanguageClientManager

... and not just the first one returned by
BaseTextEditor::textEditorForDocument

Change-Id: I39e9271b3a2b6c0f131a5ce77959a8d57e462397
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2019-03-12 13:04:41 +01:00
parent bbbf727272
commit a78bbe48cc

View File

@@ -205,22 +205,20 @@ void LanguageClientManager::editorOpened(Core::IEditor *iEditor)
for (Client *interface : reachableClients()) for (Client *interface : reachableClients())
interface->openDocument(document); interface->openDocument(document);
if (auto textDocument = qobject_cast<TextDocument *>(document)) { if (BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(iEditor)) {
if (BaseTextEditor *editor = BaseTextEditor::textEditorForDocument(textDocument)) {
if (TextEditorWidget *widget = editor->editorWidget()) { if (TextEditorWidget *widget = editor->editorWidget()) {
connect(widget, &TextEditorWidget::requestLinkAt, this, connect(widget, &TextEditorWidget::requestLinkAt, this,
[this, filePath = document->filePath()] [this, filePath = document->filePath()]
(const QTextCursor &cursor, Utils::ProcessLinkCallback &callback){ (const QTextCursor &cursor, Utils::ProcessLinkCallback &callback) {
findLinkAt(filePath, cursor, callback); findLinkAt(filePath, cursor, callback);
}); });
connect(widget, &TextEditorWidget::requestUsages, this, connect(widget, &TextEditorWidget::requestUsages, this,
[this, filePath = document->filePath()] [this, filePath = document->filePath()]
(const QTextCursor &cursor){ (const QTextCursor &cursor) {
findUsages(filePath, cursor); findUsages(filePath, cursor);
}); });
} }
} }
}
} }
void LanguageClientManager::editorsClosed(const QList<Core::IEditor *> &editors) void LanguageClientManager::editorsClosed(const QList<Core::IEditor *> &editors)